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 libc/13524] New: glibc 32: sscanf get wrong result for long double at 4e-28 and 8e-28 at Linux on Power


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

             Bug #: 13524
           Summary: glibc 32: sscanf get wrong result for long double at
                    4e-28 and 8e-28 at Linux on Power
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper.fsp@gmail.com
        ReportedBy: guojiufu@gmail.com
    Classification: Unclassified


Hardware >POWER5+ 
software 
---
#include<stdio.h>
#include<math.h>

union U { long double ld; int d[sizeof(long double)/sizeof(int)];};
void Print(long double data) {
  union U u;
  u.ld=data;
  printf("long double:%Lg\t hex:" ,u.ld);
  int i;
  for(i = 0; i < sizeof(long double)/sizeof(int);++i) printf("%0x ",u.d[i]);
  printf("\n");
}

void foo(char * str,long double b){
  long double a ;
  (void)sscanf(str, "%Le", &a);
  Print(b);
  Print(a);
  Print(a-b);
}

int main()
{
  foo("4e-28L",+4e-28L);
  foo("8e-28L",+8e-28L);
  return 0 ;
}
-----------
gcc t.c -m32;./a.out 
long double:4e-28        hex:3a3fb0f6 be506019 36d06c5e 54eb70c4
long double:4e-28        hex:3a3fb0f6 be506019 36d06c5e 54eb70e4
long double:7.96546e-59  hex:33e00000 0 0 0
long double:8e-28        hex:3a4fb0f6 be506019 36e06c5e 54eb70c4
long double:8e-28        hex:3a4fb0f6 be506019 36e06c5e 54eb70d4
long double:7.96546e-59  hex:33e00000 0 0 0
--
gcc t.c -m64;./a.out 
long double:4e-28        hex:3a3fb0f6 be506019 36d06c5e 54eb70c4
long double:4e-28        hex:3a3fb0f6 be506019 36d06c5e 54eb70c4
long double:0    hex:0 0 0 0
long double:8e-28        hex:3a4fb0f6 be506019 36e06c5e 54eb70c4
long double:8e-28        hex:3a4fb0f6 be506019 36e06c5e 54eb70c4
long double:0    hex:0 0 0 0
--

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


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