Mathematics

Exact Arithmetic with Big Numbers: Worked Examples

Ordinary floating-point math loses precision beyond about 15-17 digits, but arbitrary-precision integer arithmetic keeps every digit exact, including the remainder left over from a division.

A worked example: adding two 30-digit numbers

Enter 999999999999999999999999999999 as the first number, 1 as the second, and choose Add, and the big number calculator returns exactly 1000000000000000000000000000000 — a run of thirty 9s rolling over into a 1 followed by thirty 0s. A typical floating-point calculator would have already lost precision well before reaching numbers this size; this result is exact to the last digit.

The formula: exact arbitrary-precision arithmetic

The calculator converts both inputs to JavaScript's BigInt type, which stores whole numbers of any size without the rounding that floating-point formats impose, then applies the chosen operation directly. For the addition above that's simply 999999999999999999999999999999 + 1, computed digit-for-digit rather than approximated — which is exactly why the result carries all thirty-one digits correctly instead of rounding to something like 1e30.

A worked example: dividing with an exact remainder

Divide 100000000000000000000000000007 by 3 and the calculator returns two numbers: a result of 33333333333333333333333333335, and a remainder of 2. Big-integer division truncates toward zero rather than producing a repeating decimal, so the remainder field is what captures the leftover amount exactly — here, 3 × 33333333333333333333333333335 + 2 reconstructs the original 100000000000000000000000000007 precisely.

Why exact remainders matter

Anywhere a whole-number quantity has to be split evenly, an approximate decimal answer can hide whether the split was clean or not. Knowing the remainder is exactly 2, rather than reading a decimal result like 33333333333333333333333333335.666..., is what lets you tell at a glance that 100000000000000000000000000007 does not divide evenly by 3 and by precisely how much it falls short.