Home / Guides / Floating-point representation

Floating-point representation

A floating-point number that holds fractions is stored as bits for sign, exponent and mantissa.

Three-part structure

The IEEE 754 format splits into a sign bit, an exponent and a mantissa. A 32-bit float is 1+8+23 bits; a 64-bit double is 1+11+52 bits.

Why rounding errors happen

Even a number as simple as 0.1 in decimal becomes an infinitely repeating fraction in binary, so storing it in finite bits leaves a tiny error.

Difference from integers

The integers this tool handles are exact via BigInt, but floating-point values are approximations. Understanding the bit layout explains where the error comes from.