Floating-Point Error Calculator
Compare an expected numerical value with an actual floating-point value and calculate signed error, absolute error, relative error, percentage error, Float32 or Float64 representation error, local ULP size and approximate error measured in ULPs.
Actual − Expected. Absolute error is
its magnitude. Relative error is |Actual − Expected| / |Expected|.
When the expected value is exactly zero, conventional relative and percentage
error are undefined unless the actual error is also zero.
—
—
What Is a Floating-Point Error Calculator?
A Floating-Point Error Calculator measures the difference between an expected reference value and a numerical result. It can express the difference as an absolute amount, a signed error, a relative ratio, a percentage and an approximate number of floating-point ULPs.
The calculator can also round the entered value to IEEE 754 Binary32 or Binary64 and show how much additional error is introduced by that representation.
Signed Error Formula
Signed Error
= Actual - ExpectedA positive result means the actual value is above the expected value. A negative result means it is below the expected value.
Absolute Error Formula
Absolute error ignores the direction of the difference and measures only its magnitude.
Absolute Error
= |Actual - Expected|If the expected value is 100 and the actual value is 99.9:
|99.9 - 100|
= 0.1Relative Error Formula
Relative error compares the absolute error with the magnitude of the expected reference value.
Relative Error
= |Actual - Expected|
-------------------
|Expected|Relative error is dimensionless and makes it easier to compare errors across values with very different magnitudes.
Percentage Error Formula
Percentage Error
= Relative Error × 100%For example:
Expected = 100
Actual = 99.9
Absolute Error = 0.1
Relative Error
= 0.1 / 100
= 0.001
Percentage Error
= 0.1%What Happens When the Expected Value Is Zero?
Relative error divides by the magnitude of the expected value. Therefore a nonzero error relative to an expected value of zero does not have a finite conventional relative error.
Expected = 0
Actual = 0.001
Relative Error:
undefined / infinite comparison
because denominator = 0The calculator reports this case explicitly rather than silently dividing by zero.
Floating-Point Representation Error
A decimal number entered by a user may not be exactly representable in the selected binary floating-point format. Representation error measures the difference between the rounded stored floating-point value and the entered numeric value.
Representation Error
= Stored Float - Entered ActualThis is different from application error between an expected answer and an actual computed answer.
Example: Decimal 0.1 as Float32
The decimal fraction 0.1 cannot be represented exactly by a finite binary fraction. In Binary32 it is stored approximately as:
0.10000000149011612The difference from mathematical decimal 0.1 is approximately:
1.4901161193847657 × 10^-9This small difference is a normal consequence of binary floating-point representation.
Error Measured in ULPs
ULP means unit in the last place. Measuring an error in ULPs relates the difference to the spacing between nearby representable numbers.
Approximate ULP Error
= Absolute Error / Local ULPAn error of approximately one ULP means the numerical difference is about one floating-point step at that magnitude.
Float32 and Float64 Precision
| Format | Total Bits | Fraction Bits | Significand Precision |
|---|---|---|---|
| Float32 / Binary32 | 32 | 23 | 24 binary digits |
| Float64 / Binary64 | 64 | 52 | 53 binary digits |
Binary64 normally represents numbers much more precisely than Binary32 because it has more than twice as many fraction bits.
Rounding Error vs Measurement Error
Floating-point error is not always caused by floating-point representation. The difference between expected and actual values can come from measurement noise, numerical algorithms, approximation formulas, truncation or accumulated rounding.
The representation-error result isolates only the rounding performed when the actual input is converted to the selected Float32 or Float64 representation.
Absolute Error vs Relative Error
Absolute error is easiest to interpret when the unit and numerical scale are already meaningful. Relative error is often more useful when comparing the quality of results with different magnitudes.
Error of 1:
Expected 10
→ relative error 10%
Expected 1,000,000
→ relative error 0.0001%The same absolute difference can therefore have very different significance.
Why Floating-Point Values Are Often Approximate
Binary floating-point can exactly represent numbers whose fractional part can be expressed using a finite number of powers of two. Many familiar decimal fractions, including 0.1 and 0.2, require an infinite repeating representation in binary.
The stored value must therefore be rounded to the nearest available floating-point number.
Accumulated Floating-Point Error
A single representation error may be tiny, but repeated arithmetic can cause errors to accumulate or interact with cancellation, rounding and changing numerical scale.
Catastrophic Cancellation
When two nearly equal floating-point values are subtracted, significant leading digits can cancel and leave a result containing relatively few accurate bits. This is known as catastrophic cancellation.
a ≈ b
result = a - b
Small absolute rounding differences in a and b
can become large relative differences in result.Floating-Point Error Calculator FAQs
What is floating-point error?
What is absolute error?
What is signed error?
What is relative error?
How is percentage error calculated?
Can relative error be calculated when expected value is zero?
What is representation error?
What does error in ULPs mean?
Is one ULP always the same size?
Why is 0.1 not exact in binary floating point?
Which is more precise: Float32 or Float64?
Does a zero absolute error mean the numbers are represented identically?
Is percentage error always a good floating-point accuracy measure?
Measure Floating-Point Numerical Error
Compare expected and actual values using absolute, relative, percentage and ULP-based error while also inspecting how Float32 or Float64 storage changes the supplied number.