by shigemk2

当面は技術的なことしか書かない

97 Things Every Programmer Should Know 33 Floating-Point Numbers Aren't Real

FLOATING-POINT NUMBERS ARE NOT "REAL NUMBERS" in the mathematical sense, even though they are called real in some programming languages, such as Pascal and Fortran.

Because the spacing between adjacent floats in that range is 128, and floating-point operations round to the nearest floating-point number.

Since floating-point numbers are approximations of real numbers, there is inevitably a little error present. This error, called roundoff, can lead to surprising results.

Floating-point numbers are intended for efficient scientific computation. But efficiency is worthless without accuracy, so remember the source of rounding errors, and code accordingly!