This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

ecvt rounding problem



Hello,

I have got an bug report to ecvt().  If the ndigit parameter is
greater then the DBL_DIG constant in float.h, you will get rounding
errors. (run the attached example with parameters from 14-17 and
you will see it.

My question: is it Ok to set the ndigit variable to DBL_DIG if
it is greater in ecvt or snprintf, where the error happens ?
Or to fix it in another way ?

I don't think this is a real error. But on all other UNIX systems
except glibc based ones the output of the example is always the
same for ndigits in 14-17.

  Thorsten

#include <stdlib.h>
main(argc, argv)   
int argc;
char ** argv;
{
  int i;
  double dbl;
  char * p;
  int decpt, sign;

  for( i=0; i < 300; i++ )
  {
    dbl = i;
    p = ecvt( dbl, atoi(argv[1]), &decpt, &sign );
    printf( "%03d: %e -> %s, %d, %d\n", i, dbl, p, decpt, sign );
  }
}


-- 
Thorsten Kukuk      http://www.suse.de/~kukuk/        kukuk@suse.de
SuSE GmbH           Schanzaeckerstr. 10             90443 Nuernberg
Linux is like a Vorlon.  It is incredibly powerful, gives terse,
cryptic answers and has a lot of things going on in the background.

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