Happy Happy Joy Joy (was: On to Hydro)

Mark S. Miller markm@caplet.com
Mon, 21 Aug 2000 10:06:24 -0700


At 08:46 AM 8/21/00 , Jonathan S. Shapiro wrote:
>I was picking a nit. The question is: "What is a number?" The answer, in the
>limit, is "something that responds to zero test and summation in a
>well-defined way." Floating point values do not. The sum of two
>representable floating point values is not always a representable floating
>point value. 

Since we no longer have any reason to consider deviating from IEEE, I hope 
to make this my last post on floating point.

In making a correspondence between floating point concepts and mathematical 
real number concepts, you're certainly correct that something's gotta break. 
You propose breaking the "numberness".  I believe IEEE instead breaks the 
operators.  My understanding of the standard way to give semantics to 
floating point (called the "Brown model" or something like that maybe?), and 
one of the inspirations that led to IEEE, is to say that floating point 
values indeed denote (in the denotational semantics sense) the real numbers 
they naively denote.  The subset of real number denoted by floating point 
values are the "representable numbers".  (By these definitions, neither the 
infinities nor the NaNs denote real numbers, which is why I find it bad 
terminology that "Inf isNaN" yields false.)  However, to use your example, 
floating point "+" does not denote mathematical addition of real numbers.  
Rather, it meets the following constraints (among others) defined in terms 
of mathematical real numbers and operators.

Let's say fa and fb are two floating point values that denote real numbers.

Let's say ra and rb are these real number.  ra and rb are therefore 
representable numbers.

Let's define rc = ra + rb according to math.  Note that rc must be a real number.

Let's define fc := fa + fb according to IEEE (or any other floating point 
defined by that model whose name I don't remember).  Note that fc might not 
denote a real number.

If (rc is a representable number) {
     fc denotes rc
} else if (there are representable numbers both above and below rc) {
     fc denotes either the largest representable number below rc 
     or the smallest representable number above rc, depending on rounding mode.
} else {
     ???
}

This denotational approach is quite admirable.  Rather than say that 
floating point is just this weird type that must be understood on its own 
terms, they made a strong enough correspondence with real numbers to be 
useful.  This correspondence must be broken in the ways you point out (in 
order to meet the engineering objectives), but it's up to us whether to 
think of the numberness or the operators as broken.  I like the standard 
point of view that takes the numbers to be perfect and breaks the operators. 
I sorta know how to think about that.


         Cheers,
         --MarkM