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/13958] New: printf(3) format spec "%La" generates odd output (at least on x86)


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

             Bug #: 13958
           Summary: printf(3) format spec "%La" generates odd output (at
                    least on x86)
           Product: glibc
           Version: 2.14
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: unassigned@sourceware.org
        ReportedBy: cloos@jhcloos.com
                CC: drepper.fsp@gmail.com
    Classification: Unclassified


Some examples:

double: 1 (0x1p+0)
long double: 1 (0x8p-3)

double: 1.5 (0x1.8p+0)
long double: 1.5 (0xcp-3)

I presume this is related to the 80-bit representationâs lack of an implied
bit?

I noticed this while looking at bug #13940; this is based on Andreasâ code in
comment #1 there:


#include <stdlib.h>
#include <stdio.h>
int
main (int c, char *v[])
{
  float f;
  double d;
  long double ld;

  ld = -1.0L;
  if (c > 1)
        ld = strtold (v[1], NULL);

  f = (float)ld;
  d = (double)ld;

  printf ("float %.8g (%a)\n", f,f);
  printf ("double %.16g (%a)\n", d,d);
  printf ("long double %.20Lg (%La)\n", ld, ld);

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