|
|
|
|
|
by bewaretheirs
997 days ago
|
|
IEEE standard floating point uses a binary mantissa. And binary has trouble representing fractions that are common in prices: $ bc
obase=2
scale=20
1/5
1/5 in binary is a repeating binary fraction: 0.0011001100110011...Just as you can't express 1/3 or 1/7 precisely as a non-repeating decimal fraction, you can't express 1/5 and 1/10 as a non-repeating binary fraction. As a result, most prices involving cents in currency cannot be expressed precisely as binary floating point numbers. edit: fixed formatting |
|