← All text tools

Floating point error calculator

Enter numbers and an operation to see the stored double value, its exact decimal expansion, the rounding error and the exact result, plus how repeated sums drift.

  • Free
  • No sign-up
  • Works on any device

About Floating point error calculator

Computers store most decimal fractions as the nearest 64-bit binary double, so 0.1 is really 0.1000000000000000055511151231257827 and 0.1 + 0.2 comes out as 0.30000000000000004. This calculator reads your decimals exactly, shows the stored double of each, performs the operation as JavaScript does, and compares it with the exact decimal result using integer arithmetic. It reports the error in decimal and in units of the last place, checks the result against the number you expected, and adds a number to itself many times to show how errors accumulate.

How to use Floating point error calculator

  1. Type numbers A and B as decimals and choose addition, subtraction, multiplication or division.
  2. Optionally type the result you expected, such as 0.3, to see why it is not equal.
  3. Set how many times A is added to itself to watch the error build up.

Why use this tool?

Also known as

Frequently asked questions

Why is 0.1 + 0.2 not exactly 0.3?

Neither 0.1 nor 0.2 has an exact binary form. Their stored doubles are slightly above the decimals, and the sum rounds to a double one step above the double nearest 0.3.

What is a unit in the last place?

It is the gap between a double and the next larger one at that size. An error of 0.8 ulp means the result is off by eight tenths of that gap, which is typical of a single rounding.

How do I avoid these errors with money?

Store amounts as whole cents in integers or use a decimal number type. Compare floating-point results with a small tolerance instead of using exact equality.

Is Floating point error calculator free?

Yes. Floating point error calculator on Toolipedia is free to use, with no sign-up and no watermark.

Is it safe to use?

Yes. Everything is worked out in your browser, and nothing you enter is sent to our server.

Does it work on my phone?

Yes. It works in any modern browser on Android and iPhone, as well as on tablets and computers. There's nothing to install.

Do I need an account?

No. Just open the page and use the tool. There's no sign-up and no email needed.