8 Floating-Point Arithmetic
Greater accuracy has greater value principally to the extent that it diminishes risk.
— William Kahan
If there is one area in computer programming whose everyday programming practice borders on art, alchemy, and black magic, it is surely floating-point arithmetic. Although the scientific principles behind floating-point arithmetic are well understood, most practitioners consider them (often rightly) arcane, esoteric, and difficult to apply in practice. As is typically the case when superstition takes the place of science, the field is ripe with both popular misconceptions (“drinking alcohol warms your body”) and sensible rules of a thumb (“it is bad luck to pass under a ladder”).
As an example, consider how our notions ...