Movement against float.init being nan

Paul Backus snarwin at gmail.com
Sat Aug 20 21:11:23 UTC 2022


On Saturday, 20 August 2022 at 18:59:40 UTC, IGotD- wrote:
> I never understood why the IEEE standard decided to include 
> infinity. What were they trying to achieve? Indeterminate maths 
> with floating point?

I was curious about this too, so I did some searching. The 
Wikipedia page on floating-point arithmetic has a section titled 
"IEEE 754 design rationale" [1], which cites as one of its 
sources "Why do we need a floating-point arithmetic standard?" 
[2], a 1981 paper by William Kahan, one of the designers of IEEE 
754.

In that paper (on page 31), Kahan gives the following rationale 
for including values like NaN and infinities:

> the proposed standard specifies rules for creating and 
> manipulating sym-
> bols like ±0, ±∞ and NaN – the symbol “NaN ” stands for “Not a 
> Number”.
> These rules are designed so that a programmer may frequently 
> omit tests and
> branches that were previously obligatory because computers 
> treated exceptions
> in unpredictable or capricious ways.
> [...]
> At the
> same time as NaN is created a flag called Invalid Operation is 
> raised. Subse-
> quently the calling program may infer either from this flag or 
> from the NaN that
> an emergency arose and may cope with it automatically rather 
> than abort

So the point is to simplify error handling, and to allow error 
handling to be deferred.

[1] 
https://en.wikipedia.org/wiki/Floating-point_arithmetic#IEEE_754_design_rationale
[2] 
https://people.eecs.berkeley.edu/~wkahan/ieee754status/why-ieee.pdf


More information about the Digitalmars-d mailing list