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

#1 2009-05-26 14:58:15

TinyWanda
Scratcher
Registered: 2009-05-26
Posts: 35

Multiplying a Small Number...

A Script that i was working on recently was driving me crazy because it would --Almost-- work...
So i tediously worked though each step, and then created a secondary list that recorded each value as it generated in this loop...
And discovered to my astonishment that this one loop, which subtracted one value from another and then multiplied that by 10, worked again & again,
Until the numbers became kind of small,
and 6.43 - 6 Then x 10
Resulted in 4.29999999999998
And there after; This was the number that the loop used in the nest itineration...!
i managed to fix it, but it required a very ugly kludge in the middle of the script.
This occurs in my IsThisNumberPrime? Script; SubScript WholeToList.
???


Visit The Source Material...
http://transamoebae.blogspot.com/

Offline

 

#2 2009-05-26 16:18:08

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Multiplying a Small Number...

That's odd - are you sure you're using brackets correctly?

Offline

 

#3 2009-05-26 16:57:54

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

Re: Multiplying a Small Number...

Floating point numbers (numbers with a decimal point) on computers are often an approximation, due to the limited number of bits available to represent them.   You have to design your algorithms around those limitations - it can be a challenge  smile


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

Offline

 

Board footer