[Bug math/887] Math library function "logb" and "nextafter" inconsistent

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Bug math/887] Math library function "logb" and "nextafter" inconsistent

fweimer at redhat dot com

------- Additional Comments From rsa at us dot ibm dot com  2006-09-30 05:54 -------
The behavior following fesetround(FE_DOWNWARD) is exhibited on the fsub
operation where f0 and f13 are the same both times fsub is called (before and
after the rounding mode is set):

10000390:       fc 0d 00 28     fsub    f0,f13,f0

The bug doesn't have anything to do with GCC.  The rounding mode is set in the
fpu's FPSCR using the fesetround() function and is applied to the fsub operation.

According to the PowerPC architecture specification for the fsub operation "The
result is rounded to the target precision under control of the Floating-Point
Rounding Control field RN of the FPSCR and placed into register FRT."

Indeed, when the -0.0 result is encountered from fsub following
fesetround(FE_DOWNWARD) the fpscr's rounding mode bits are set for '11' "Round
toward - Infinity":

fpscr          0x4003   16387

And when the 0.0 result is encountered from fsub prior to
fesetround(FE_DOWNWARD) the fpscr's rounding mode bits are set to '00' "Round to
Nearest"

fpscr          0x4000   16384

At worst we're simply encountering the processor defined behavior for fsub.

I reviewed the C99 spec and IEEE754r and could find no mention of logb behavior
regarding rounding mode.  It simply appears to be undefined.

The implementation of logb() makes use of fsub and an identical result is
encountered there.

This same behavior was exhibited on i386.


--


http://sourceware.org/bugzilla/show_bug.cgi?id=887

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.