Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How comes my computer calculate into this?
#3
You mean -0.0999... - which is a pretty significant difference.

Nowhere! The computer calculates 0.9 - (0.5 * (i - 1)) by first calculating i - 1 = 2, then 0.5 * 2 = 1.0. Finally, it computes 0.9 - 1.0 to either -0.0999999978 or -0.100000024 because of floating point accuracy problem: As the computer only sees 1s and 0s, it cannot represent -0.10 in any way without using fractions. Fractions are usually slow, and are thus not used unless specified.

It is probably easier to understand if you compare it with some fraction we can't express properly: 1/3. If we say 1/3 * 3 to a computer, it can actually compute it correctly, but if we say it to a "human computer", it would first calculate 1/3 = 0.3333333... and then multiply it by 3, which is 0.9999999....

Noah
Reply


Messages In This Thread
How comes my computer calculate into this? - by Noah - 2011-06-19, 11:45 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)