Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » 1.1 x 3 variables
- Trazam
- Scratcher
2 posts
1.1 x 3 variables
so im making this game about planet clickers and i got this glitch were scratch if you 1.1x 3 it makes it 3.3000003 which makes my cool funky numbers not work now please if you can i need help to either somehow find a way to go around this or to make it so my cool funky numbers dont actually bug out on this weird thing
Last edited by Trazam (May 13, 2024 02:08:30)
- Trazam
- Scratcher
2 posts
1.1 x 3 variables
ah i got it ty but now it does it with 7s and makes it 7.000000001 instead
Last edited by Trazam (May 13, 2024 02:27:24)
- Jlerpy
- Scratcher
500+ posts
1.1 x 3 variables
Our old friend the floating point error. TUB's solution really should address the 7 version as well.
- deck26
- Scratcher
1000+ posts
1.1 x 3 variables
Imagine I asked you to write 1/3 as a decimal fraction exactly and without using the trick of marking it as a repeating value. You just can't do it since it is 0.333 continuing for ever.
Now computers don't use decimal, they use binary, and even storing some values we find easy like 1/10 = 0.1 a computer can't easily represent so it has to approximate depending how many bytes it uses to store the value. So you get results like you're seeing and it is up to you to round these if they don't appear the way you want.
Now computers don't use decimal, they use binary, and even storing some values we find easy like 1/10 = 0.1 a computer can't easily represent so it has to approximate depending how many bytes it uses to store the value. So you get results like you're seeing and it is up to you to round these if they don't appear the way you want.
- Discussion Forums
- » Help with Scripts
- » 1.1 x 3 variables