[patch] math.h fixes

Howland Craig D (Craig) howland@LGSInnovations.com
Thu Apr 2 12:59:00 GMT 2009

If I had realized that llrint() llrintf() were missing when I added
the documentation, I would have supplied the functions as I did for
llround.  (I had based my evaluation of whether functions existed or
not on math.h, which is obviously the wrong way of checking.  I'll have
to re-check for missing functions in a more vigorous way.)
I have created llrint() and llrintf() from the existing lrint() and
lrintf() functions.  They have been tested and compared against the
RHEL5 library (GLIBCx) and pass almost all test cases.  llrint()
fails a single test case, but lrint() fails exactly the same single
case.  It actually appears to be an Intel problem, as the rounding is
done by the floating point hardware, not in the s_llrint.c/s_lrint.c
source code.  Because of these two reasons, I'm submitting it despite
the one incorrect case.
The specific case that fails is:
	double arg=1.5-LBDL_EPSILON;
	lrint( arg) and llrint( arg) return 2, and
	lrint(-arg) and llrint(-arg) return -2,
when rounding is set to FE_NEAREST.
The correct answers are 1 and -1.  The same value with the other 3
rounding modes works fine.  The test case of 1.5+LDBL_EPSILON passes (in
all rounding modes).
Since my addition messes up Ken's patch, I've adjusted his patch
(math.h.patch) and included it, too (skipping the qualifiers for

-----Original Message-----
From: newlib-owner@sourceware.org [mailto:newlib-owner@sourceware.org]
On Behalf Of Ken Werner
Sent: Wednesday, April 01, 2009 4:37 PM
To: newlib@sourceware.org
Subject: [patch] math.h fixes


this patch removes the duplicate copysign prototype and fixes a typo. In

addition it guards the rint family because there are implemented on i386


-------------- next part --------------
A non-text attachment was scrubbed...
Name: llrint.patch
Type: application/octet-stream
Size: 7100 bytes
Desc: llrint.patch
URL: <http://sourceware.org/pipermail/newlib/attachments/20090402/8c5e97a6/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ChangeLog
Type: application/octet-stream
Size: 235 bytes
Desc: ChangeLog
URL: <http://sourceware.org/pipermail/newlib/attachments/20090402/8c5e97a6/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: math.h.patch
Type: application/octet-stream
Size: 2034 bytes
Desc: math.h.patch
URL: <http://sourceware.org/pipermail/newlib/attachments/20090402/8c5e97a6/attachment-0002.obj>

More information about the Newlib mailing list