On Fri, Oct 23, 2015 at 9:46 AM, Keith Medcalf <kmedcalf at dessus.com> wrote:

> You are thinking (and typing) in base 10.  Computers use this new-fangled
> thing called binary -- base 2.
> The "floating point" type is IEEE 754 double precision binary (base 2)
> floating point.
>

https://en.wikipedia.org/wiki/Double-precision_floating-point_format

Basically, each bit in the mantissa represents a power-of-2 fraction. And
the sum of these fractions gives you what comes after the decimal point
(adjusted for the exponent).

So 1.75 is exact in IEEE since 1/2 + 1/4 = 0.75, but other simple numbers'
decimal part can't be represented exactly using such a sum of power-of-2
fractions (1/(2^i)), and you get the closest number it can represent,
typically with an error around 1/(2^52) for an 8-byte double.

Another good good way to think of IEEE I was presented once with, and which
kind of gave me a ah-ah moment, is the fact that numbers with exact
representation fall on the nodes of grid, and there's plenty of "space" in
between the nodes for values which cannot be exactly represented. The
"spacing" of the grid varies depending on the magnitude of your number
(i.e. the exponent) and the size of the mantissa (i.e. how small your 1/2^i
fractions get). IEEE is complex... I'm not an expert, but hopefully the
above helps. --DD

Reply via email to