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

#1 2011-09-16 12:45:25

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

numbers operations bug-this isn't just a stupid programming mistake!

http://dl.dropbox.com/u/38975042/floating%20point%20bug.gif
For some reasons, Scratch calculates it false.

EDIT: Oops, reporting for moving to Troubleshooting...
SECOND EDIT: thanks!

Last edited by roijac (2011-09-16 13:11:42)

Offline

 

#2 2011-09-16 13:11:25

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: numbers operations bug-this isn't just a stupid programming mistake!

Because decimal numbers can not be represented exactly in Scratch (or many other computer languages for that matter), any exact comparison of decimal numbers can be problematic.  Sometimes it works and sometimes it doesn't.  It's a lot safer to work with integers - you could scale all the numbers up by 1000 and then use the Round function to turn them into integers.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#3 2011-09-16 13:14:18

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

Re: numbers operations bug-this isn't just a stupid programming mistake!

oh, thanks, i didn't try using rounding...
so now i have a way to store 2 different numbers and a letter in only ONE variable/string  big_smile  (means my (no more) secret compiler will come out sooner  smile  )

Last edited by roijac (2011-09-16 13:14:42)

Offline

 

Board footer