This is the mail archive of the glibc-bugs@sourceware.org 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/4997] New: lround(nexafter(0.5,-1)) has incorrect value


On powerpc-unknown-linux-gnu, with GNU C Library development release version 2.4
(20060617), lround(nextafter(0.5,-1)) returns 1 instead of the expected 0.


PS: it appears that powerpc glibc-2.6 is calculating lround(x) by converting
(x+0.5) into an integer (thanks to David Edelsohn for pointing that to me):

    fcmpu   cr6,fp1,fp12    /* if (x > 0.0)  */
    ble-    cr6,.L4
    fadd    fp1,fp1,fp10    /* x+= 0.5;  */
    fctiwz  fp2,fp1         /* Convert To Integer DW lround toward 0.  */
.L4:
    fsub    fp1,fp1,fp10    /* x-= 0.5;  */

I think 0.5 needs to be changed into nextafter(0.5,-1). Details of why can be
found here: http://gcc.gnu.org/ml/fortran/2005-04/msg00139.html

-- 
           Summary: lround(nexafter(0.5,-1)) has incorrect value
           Product: glibc
           Version: 2.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: math
        AssignedTo: aj at suse dot de
        ReportedBy: fxcoudert at gcc dot gnu dot org
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: powerpc-unknown-linux-gnu
  GCC host triplet: powerpc-unknown-linux-gnu
GCC target triplet: powerpc-unknown-linux-gnu


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

------- 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]