This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-02-04 19:16:28

clindberg
New Scratcher
Registered: 2013-02-04
Posts: 2

Getting more detail in scratch.

I've created a simple script that uses the sine function to draw a triangle. That works beautifully. However, I need more detail in the output.

Is there a way to increase the number of digits displayed by a variable?
How many digits does the sine function output given a whole angle input?

Thanks, Chris

[scratch blocks]
when gf clicked
clear
set angle to 0
set sine to 0
set opposite to 0
hide
ask (What is the angle?) and wait
set angle to answer
set sprite3x to cos(angle) * 250

Offline

 

#2 2013-02-04 19:26:32

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Getting more detail in scratch.

clindberg wrote:

I've created a simple script that uses the sine function to draw a triangle. That works beautifully. However, I need more detail in the output.

Is there a way to increase the number of digits displayed by a variable?
How many digits does the sine function output given a whole angle input?

Thanks, Chris

when gf clicked
clear
set [angle v] to 0
set [sine v] to 0
set [opposite v] to 0
hide
ask [What is the angle?] and wait
set [angle v] to (answer)
set [sprite3x v] to ([cos v] of ((angle) * (250)))

Fixing your scratchblocks.... please give a moment.
Assuming this is what you mean?

Last edited by Firedrake969 (2013-02-04 19:28:17)


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#3 2013-02-05 12:03:40

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Getting more detail in scratch.

Firedrake969 wrote:

clindberg wrote:

I've created a simple script that uses the sine function to draw a triangle. That works beautifully. However, I need more detail in the output.

Is there a way to increase the number of digits displayed by a variable?
How many digits does the sine function output given a whole angle input?

Thanks, Chris

when gf clicked
clear
set [angle v] to [0]
set [sine v] to [0]
set [opposite v] to [0]
hide
ask [What is the angle?] and wait
set [angle v] to (answer)
set [sprite3x v] to ([cos v] of ((angle) * (250)))

Fixing your scratchblocks.... please give a moment.
Assuming this is what you mean?

There, that should fix it. Is this what you mean?


Why are the secret organizations getting all the attention?  mad

Offline

 

#4 2013-02-05 12:36:22

dechan
Scratcher
Registered: 2012-12-20
Posts: 69

Re: Getting more detail in scratch.

clindberg wrote:

I've created a simple script that uses the sine function to draw a triangle. That works beautifully. However, I need more detail in the output.

Is there a way to increase the number of digits displayed by a variable?
How many digits does the sine function output given a whole angle input?

You've touched upon one of the "magical" issues with Scratch.
We don't have precision setting for numeric output.
We also cannot specify a location for output.
I've seen everything from 3 to 15 digit mantissas so there's some floating-point library fun behind the scenes and displayed variables have a tendency to stack in a column along the left-hand side of the screen even after they've been saved in other positions.

Offline

 

Board footer