Decimal Precision Calculator

Exact base-10 arithmetic backed by BigInt scaled integers, with five rounding modes and a live IEEE 754 floating-point comparison.

Private by architecture: All processing is 100% client-side memory. Your data never leaves this browser tab.

Operands & Rounding

Exact Decimal Result

Rounded (4 places, half-up)
0.3000
Unrounded exact value
0.3
Comparison (A vs B)
A < B

IEEE 754 64-bit Float Comparison (A + B)

Shows what JavaScript Number(A) + Number(B) computes in 64-bit binary floating point versus exact base-10 addition.

Exact decimal A + B 0.3
JavaScript Number(A) + Number(B) 0.30000000000000004
Matches exact decimal? No: binary rounding error present
Nearest IEEE 754 double to A
Nearest IEEE 754 double to B
Exact stored double of (A + B)

About This Tool

Standard JavaScript numbers use 64-bit IEEE 754 binary floating point, which cannot represent base-10 fractions like 0.1 or 0.2 exactly. Adding 0.1 and 0.2 in binary floating point produces 0.30000000000000004. Financial calculations, tax rounding, and unit pricing need exact base-10 arithmetic.

This calculator parses every input into a BigInt scaled integer (int / 10^scale) up to 1,000 decimal places. Addition, subtraction, and multiplication are computed with zero intermediate rounding, then rounded to your target scale using the rounding mode you select. A side-by-side IEEE 754 inspector shows the exact base-10 expansion of the nearest 64-bit float.

Key Features

  • BigInt scaled decimal engine: Stores numbers as exact base-10 integers and scales up to 1,000 decimal places with no binary float conversion.
  • Five rounding modes: Half-up, Half-even (banker's rounding), Floor, Ceiling, and Truncate.
  • Exact and rounded output: View both the unrounded exact result (for add, subtract, multiply) and the rounded result at your chosen decimal scale.
  • IEEE 754 float comparison: Inspect what a 64-bit binary float actually stores in memory and why 0.1 + 0.2 does not equal 0.3.
  • Thousands grouping toggle: Format large numbers with comma separators for readability while copying either raw or grouped output.

Frequently Asked Questions

Why does 0.1 + 0.2 equal 0.30000000000000004 in JavaScript?
IEEE 754 double-precision numbers use base-2 fractions. Just as 1/3 is a repeating decimal in base 10 (0.333...), 1/10 (0.1) is a repeating fraction in base 2. When rounded to 53 bits of significand, 0.1 is stored as 0.1000000000000000055511151231257827021181583404541015625. Adding the rounded binary approximations of 0.1 and 0.2 produces a number slightly larger than 0.3.
What is the difference between Half-up and Half-even rounding?
Both round to the nearest neighbor unless the discarded fraction is an exact 0.5 tie. On a tie, Half-up always rounds away from zero (2.5 becomes 3, -2.5 becomes -3), while Half-even (banker's rounding) rounds to the nearest even last digit (2.5 becomes 2, 3.5 becomes 4) to prevent upward bias across many summed transactions.
How is division handled when a fraction repeats forever?
Unlike addition, subtraction, and multiplication, base-10 division such as 1 / 3 has no finite exact decimal representation. Division computes the quotient directly to your chosen number of decimal places and applies the selected rounding mode to the remainder.
Can I paste numbers with commas or scientific notation?
Yes. Commas and underscores are stripped before parsing, and scientific notation such as 1.5e-4 is expanded into its exact decimal scale.