[LLVMbugs] [Bug 3359] New: fmod in APFloat is badly broken

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Jan 20 03:56:35 PST 2009


http://llvm.org/bugs/show_bug.cgi?id=3359

           Summary: fmod in APFloat is badly broken
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: NetBSD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Support Libraries
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: neil at daikokuya.co.uk
                CC: llvmbugs at cs.uiuc.edu


Just some of the things wrong with it:

a) It takes a rounding mode.  The result is always exact, so a rounding mode
should not be an argument.

b) It doesn't handle specials (NaN, zero, infinity).

c) It gets standard cases wrong, e.g.


#include <math.h>
#include <stdio.h>

int main (void)
{
  float x = 0x1.345672p30;
  float y = 0x1.56789ap-20;
  float z1 = fmod (x, y), z2 = remainder (x,y );

  printf ("%a %a: fmod = %a remainder = %a\n", x, y, z1, z2);

  return 0;  
};

gives on NetBSD:

0x1.345672p+30 0x1.56789ap-20: fmod = 0x1.0f7dbap-20 remainder = -0x1.1beb8p-22

and for APFloat:

int main (void)
{
  char dst[30];

  APFloat x (APFloat::IEEEsingle, "0x1.345672p+30");
  APFloat y (APFloat::IEEEsingle, "0x1.56789ap-20");

  x.convertToHexString (dst, 0, false, APFloat::rmNearestTiesToEven);
  printf ("x: %s\n", dst);
  y.convertToHexString (dst, 0, false, APFloat::rmNearestTiesToEven);
  printf ("y: %s\n", dst);
  x.fmod(y, APFloat::rmNearestTiesToEven);
  x.convertToHexString (dst, 0, false, APFloat::rmNearestTiesToEven);
  printf ("mod: %s\n", dst);

  return 0;
}

gives:

x: 0x1.345672p30
y: 0x1.56789ap-20
mod: 0x0p0


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list