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

#1 2012-01-09 18:48:53

darty11
Scratcher
Registered: 2011-09-08
Posts: 1

sine and cosine calculations don't work right at 180(sin) and 90(cos)

the name really says it all. If you put 180 in the sine calculator you get 1.22somthin and if you put 90 in the cosine calculator you get the same thing!

Offline

 

#2 2012-01-10 20:23:03

VirtualClown
Scratcher
Registered: 2011-08-05
Posts: 55

Re: sine and cosine calculations don't work right at 180(sin) and 90(cos)

That means about 0.0000000000000000000000122 etc. It's very weird, and it makes it annoying when multiplying sin/cos by enormous numbers.

Offline

 

#3 2012-01-13 18:38:57

SJRCS_011
Scratcher
Registered: 2011-02-07
Posts: 1000+

Re: sine and cosine calculations don't work right at 180(sin) and 90(cos)

This is larger than you think, actually.
If you have
sin of 3.14
you get http://i.imgur.com/SmaaR.jpg
when you set a variable to it, you get http://i.imgur.com/Zj9a5.jpg


http://i.imgur.com/vQqtH.png
Learning to Program in a Nutshell:  "You're missing a closing parentheses" - LS97

Offline

 

#4 2012-04-01 15:01:50

360-International
Scratcher
Registered: 2011-07-17
Posts: 100+

Re: sine and cosine calculations don't work right at 180(sin) and 90(cos)

SJRCS_011 wrote:

This is larger than you think, actually.
If you have
sin of 3.14
you get http://i.imgur.com/SmaaR.jpg
when you set a variable to it, you get http://i.imgur.com/Zj9a5.jpg

The variable watcher rounds to the nearest 0.1, but the actual variable is equal to sin(3.14).


https://lh4.googleusercontent.com/Oib6kyze-OrCFIRlqL6HYnWuHBQp1GfFoh5CkBlZGe3_9WCk-_DDwgfFrnD_mxJ_x2b18hMUyV2KVtIDiLdebyWaQQ6fbpKpZs-8auVep1zoSgOv-iA

Offline

 

#5 2012-04-01 15:13:45

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: sine and cosine calculations don't work right at 180(sin) and 90(cos)

Offline

 

#6 2012-04-01 15:16:56

360-International
Scratcher
Registered: 2011-07-17
Posts: 100+

Re: sine and cosine calculations don't work right at 180(sin) and 90(cos)

roijac wrote:

read that

Aw, I was gonna say that.


https://lh4.googleusercontent.com/Oib6kyze-OrCFIRlqL6HYnWuHBQp1GfFoh5CkBlZGe3_9WCk-_DDwgfFrnD_mxJ_x2b18hMUyV2KVtIDiLdebyWaQQ6fbpKpZs-8auVep1zoSgOv-iA

Offline

 

#7 2012-05-20 17:57:56

3sal2
Scratcher
Registered: 2012-03-22
Posts: 100+

Re: sine and cosine calculations don't work right at 180(sin) and 90(cos)

You mean offline? Well, that's normal. Squeak can only report values of trigonometric functions exactly up to a certain point. From that point on, its accuracy diminishes.


http://scratch.mit.edu/static/projects/3sal2/3120946_sm.png In 2012, scientists at the LHC discovered the Higgs boson, which explains the source of the masses of the W+, W-, and Z bosons, as well as fermions.

Offline

 

#8 2012-06-04 14:56:38

3sal2
Scratcher
Registered: 2012-03-22
Posts: 100+

Re: sine and cosine calculations don't work right at 180(sin) and 90(cos)

It also happens with the

([tan v] of (180))
block!!!  yikes


http://scratch.mit.edu/static/projects/3sal2/3120946_sm.png In 2012, scientists at the LHC discovered the Higgs boson, which explains the source of the masses of the W+, W-, and Z bosons, as well as fermions.

Offline

 

#9 2012-06-11 04:19:35

Wes64
Scratcher
Registered: 2011-08-19
Posts: 1000+

Re: sine and cosine calculations don't work right at 180(sin) and 90(cos)

3sal2 wrote:

It also happens with the

([tan v] of (180))
block!!!  yikes

roijac wrote:

read that


Experienced 2.0 Tester: Ask me questions!
Using Firefox 13.0, Flash plugin version 11.4.402.287, and Windows XP Professional.

Offline

 

#10 2012-06-25 18:55:52

scratchisthebest
Scratcher
Registered: 2009-02-08
Posts: 500+

Re: sine and cosine calculations don't work right at 180(sin) and 90(cos)

Yeah, with computers, you only get so many significant decimal places. Anything past that amount is just garbage. On 64bit systems, you might get different results.


bye 1.4, we all loved you. but we all outgrew the site. 2.0 is a welcome change.
http://scratch.mit.edu/img/Pico3-med.pnghttp://scratch.mit.edu/img/Pico3-med.pnghttp://scratch.mit.edu/img/Pico3-med.pnghttp://scratch.mit.edu/img/Pico3-med.pnghttp://scratch.mit.edu/img/Pico3-med.png

Offline

 

#11 2012-07-10 14:04:32

3sal2
Scratcher
Registered: 2012-03-22
Posts: 100+

Re: sine and cosine calculations don't work right at 180(sin) and 90(cos)

It's currently the maximum computer accuracy. Think about Planck's constant (about 6*10^-34).


http://scratch.mit.edu/static/projects/3sal2/3120946_sm.png In 2012, scientists at the LHC discovered the Higgs boson, which explains the source of the masses of the W+, W-, and Z bosons, as well as fermions.

Offline

 

Board footer