DEV Community

Discussion on: When Math Fails You

Collapse
 
jdsteinhauser profile image
Jason Steinhauser

Good question! So the powers lead to large values, but the precision being lost is due to there being data lost at lower values. For example, if I add 1,000,000,000 and 0.00000005, I have values at two very different orders of magnitude. In all likelihood, in single precision (at least, maybe double precision also), I will lose that data behind the decimal place. Effectively, I'll end up with a stored floating point value of 1,000,000,000, and not 1,000,000,000.00000005. Floating points work very well when you have data in similar orders of magnitude, but not in the above example.

Hopefully that clears some things up! If not, I'd be happy to try to provide a better explanation :-)