Zum Inhalt springenSkip to content

Configure your inputs and press Compute to see the step-by-step computation.

How it works

Floating-point cGK,k,n encodes a real in normalised form m * 2e: 1 sign bit, n-k characteristic bits (Excess-q with q = 2n-k-1 - 1), k-1 mantissa bits (fixed-point without leading 1). Reserved bit patterns for zero, ±infinity, NaN and subnormals. Absolute rounding error grows with the exponent, but relative error stays bounded by 2-k.

Rounding error

For floating-point encoding the absolute error grows with the exponent, but the relative error stays bounded by a constant — equal precision across all magnitudes.

Maximum absolute error
2e / 2k (worst case bei e = q = 1: ≈ 0.03125)
Maximum relative error
1 / 2k = 1 / 26 = 0.015625 (konstant)

Press "Compute" to see the actual error of your current input.

When to use

In C provided as float (binary32, k=24, n=32) and double (binary64, k=53, n=64). Because of catastrophic cancellation and non-associative arithmetic, sum numbers grouped by magnitude. Always compare with a tolerance instead of ==.

Frequently asked questions

What is the difference between fixed point and floating point?

In fixed point the binary point sits at a fixed position, the absolute error is the same everywhere and the range is small. Floating point stores a mantissa and an exponent, so the point moves with the magnitude. This makes the range very large, and the relative error stays the same across all magnitudes.

How is an IEEE 754 float built?

A float (binary32) has 32 bits: 1 sign bit, 8 exponent bits in excess-127 code and 23 mantissa bits without the leading 1, which is fixed by normalisation. A double (binary64) has 1 sign bit, 11 exponent bits in excess-1023 code and 52 mantissa bits.

Why is 0.1 + 0.2 not exactly 0.3?

0.1 and 0.2 have no finite representation in binary, just like 1/3 in decimal. Both are rounded to the nearest representable number, and their sum does not hit the rounded 0.3 exactly. In double, 0.1 + 0.2 therefore gives 0.30000000000000004. Floating point numbers are compared with a tolerance, not with ==.