Two Answers on IEEE Arithmetic

David G. Hough at validgh dgh
Tue Feb 1 15:59:59 PST 1994


> 1)  Jim Thomas' "Floating-Point C Extensions" document states that
> 
> 	nextafter(x,y) returns y if x==y
> 
>     and also states that this differs from the IEEE standard (which
>     states tha that it should return x).  I was just wondering why this
>     deviation from the IEEE standard and why did the standard specify x
>     should be returned for this case?

In general, the second argument of nextafter only specifies the direction
of movement and thus, in principle, needn't even be the same type as x.
The x==y but they're slightly different would seem to be the case where
both are zeros of different sign.    There it makes sense that, if you
were at -0 and told to move toward +0, you would want a result +0,
and conversely.   Perhaps there's an application to interval arithmetic
here.

> 2)  How is the INEXACT flag used in an application?  I was asked recently
>     about how users might use the inexact flag in an application.  Are
>     there applications that use it?  If so, how is it used?

It's not uncommon to have floating-point multiplication be faster than
integer, e.g. on older SPARCS and older Crays, to name two.   So it makes
sense to do number theory with integers in floating-point formats until
you encounter a rounding error, in which case you'd have to switch to
another slower algorithm.

I use the inexact flag to get faster correctly-rounded base conversion.
You can't use the floating-point multiply or divide unless you know whether
it worked or not, if you want correctly-rounded results.    Anybody running
Solaris 2, and many running SunOS 4.x who use fix_libc, are counting on this,
whether they know it or not.



More information about the Numeric-interest mailing list