What Every Programmer Should Know About Floating-Point Arithmetic

or

Why don’t my numbers add up?

So you’ve written some absurdly simple code, say for example:

	0.1 + 0.2

and got a really unexpected result:

	0.30000000000000004

Maybe you asked for help on some forum and got pointed to a long article with lots of formulas that didn’t seem to help with your problem.

Well, this site is here to:

You should look at the Basic Answers first - but don’t stop there!

© Published at floating-point-gui.de under the Creative Commons Attribution License (BY)

Fork me on GitHub