This is the mail archive of the glibc-bugs@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug math/602] powerpc rint() function is buggy in the rounding toward -inf and +inf modes


------- Additional Comments From vincent+libc at vinc17 dot org  2004-12-15 00:37 -------
Some additional information... Here's a part of the output of my program (on a
PowerPC machine):

ay:~/wd/src/fp> ./nearestint 4.5 1
[...]
Rounding toward -oo
             -4.5  -3.5  -2.5  -1.5  -0.5   0.5   1.5   2.5   3.5   4.5
casttoint    -4    -3    -2    -1     0     0     1     2     3     4  
trunc        -4.0  -3.0  -2.0  -1.0  -0.0   0.0   1.0   2.0   3.0   4.0
floor        -5.0  -4.0  -3.0  -2.0  -1.0   0.0   1.0   2.0   3.0   4.0
ceil         -4.0  -3.0  -2.0  -1.0  -0.0   1.0   2.0   3.0   4.0   5.0
round        -5.0  -4.0  -3.0  -2.0  -1.0   1.0   2.0   3.0   4.0   5.0
nearbyint    -5.0  -4.0  -3.0  -2.0  -1.0   0.0   1.0   2.0   3.0   4.0
myrint       -5.0  -4.0  -3.0  -2.0  -1.0   0.0   1.0   2.0   3.0   4.0
rint         -4.0  -3.0  -2.0  -1.0   0.0  -0.0   1.0   2.0   3.0   4.0
[...]

"myrint" corresponds to my code. As expected, it agrees with the nearbyint glibc
function (which is correct). In short, the current rint code for negative
numbers doesn't work in the rounding modes toward -oo and toward +oo, because it
does the first subtraction in the wrong way, so that the result is rounded in
the wrong direction.

Note: do not try the code on Linux/x86, or any other processor that runs in
extended precision; it will not work (in part due to a gcc bug). Well, if you
really want to try on such a machine, you can still use the -ffloat-store
compiler switch, but the results are not guaranteed for any input.

-- 


http://sources.redhat.com/bugzilla/show_bug.cgi?id=602

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]