Discuss Scratch
- Discussion Forums
- » Bugs and Glitches
- » 10 ^ x block is innacurate
- MrSherlockHolmes
-
Scratcher
500+ posts
10 ^ x block is innacurate
([10 ^ v] of (2))Gives you 99.9999998, surely it's just 100!

With 10^3 it gives 999.999998?
Can someone explain this? Thanks
SH
- Doodle-cats
-
Scratcher
500+ posts
10 ^ x block is innacurate
I think a better place for this would be in “Bugs And Glitches” forum 

- MrSherlockHolmes
-
Scratcher
500+ posts
10 ^ x block is innacurate
I think a better place for this would be in “Bugs And Glitches” forumGood point.

- Doodle-cats
-
Scratcher
500+ posts
10 ^ x block is innacurate
You could tell Paddle2See to maybe move this discussionI think a better place for this would be in “Bugs And Glitches” forumGood point.
- MrSherlockHolmes
-
Scratcher
500+ posts
10 ^ x block is innacurate
KYou could tell Paddle2See to maybe move this discussionI think a better place for this would be in “Bugs And Glitches” forumGood point.
- TheLogFather
-
Scratcher
1000+ posts
10 ^ x block is innacurate
Welcome to the joys of floating-point arithmetic… 
Now, you might be thinking that you haven't used any non-integer numbers (I mean ten… to the power of two…?!), but that doesn't mean the computer hasn't.
Under the hood, powers are generally worked out using the formula x ^ y = e ^ y*(lnx)
That means 10^2 is e^2*ln(10). Unfortunately, both e and ln(2) are not whole numbers, so you've now entered the realm of inexact floating-point arithmetic…
I've got a project which contains a generalised power-of custom block:

http://scratch.mit.edu/projects/16871883
One of its features is that it detects when both x & y are integers and rounds the result (as well as constructing integer powers of ten using text containing a one & zeros, plus decimal point for 10^negative).
Hope that makes sense of it!

Now, you might be thinking that you haven't used any non-integer numbers (I mean ten… to the power of two…?!), but that doesn't mean the computer hasn't.
Under the hood, powers are generally worked out using the formula x ^ y = e ^ y*(lnx)
That means 10^2 is e^2*ln(10). Unfortunately, both e and ln(2) are not whole numbers, so you've now entered the realm of inexact floating-point arithmetic…

I've got a project which contains a generalised power-of custom block:

http://scratch.mit.edu/projects/16871883
One of its features is that it detects when both x & y are integers and rounds the result (as well as constructing integer powers of ten using text containing a one & zeros, plus decimal point for 10^negative).
Hope that makes sense of it!
Last edited by TheLogFather (Jan. 18, 2015 16:50:28)
- MrSherlockHolmes
-
Scratcher
500+ posts
10 ^ x block is innacurate
Welcome to the joys of floating-point arithmetic…Thanks!
Now, you might be thinking that you haven't used any non-integer numbers (I mean ten… to the power of two…?!), but that doesn't mean the computer hasn't.
Under the hood, powers are generally worked out using the formula x ^ y = e ^ y*(lnx)
That means 10^2 is e^2*ln(10). Unfortunately, both e and ln(2) are not whole numbers, so you've now entered the realm of inexact floating-point arithmetic…
I've got a project which contains a generalised power-of custom block:
http://scratch.mit.edu/projects/16871883
One of its features is that it detects when both x & y are integers and rounds the result (as well as constructing integer powers of ten using text containing a one & zeros, plus decimal point for 10^negative).
Hope that makes sense of it!
- Discussion Forums
- » Bugs and Glitches
-
» 10 ^ x block is innacurate


