This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


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

vfnprintf


Hello all,

I have a problem when using printf.
for example

printf("%.*E\n",16,MAXDOUBLE);

the result is
1.797693134862317E3080

but it's incorrect, ZERO padding is too much.

correct answer is
1.7976931348623170E308

I found the part of padding in vfnprintf
     391                         if (prec > MAXFRACT) {
     392                                 if ((ch != 'g' && ch != 'G') || 
(flags&ALT))
     393                                         fpprec = prec - MAXFRACT;
     394                                 prec = MAXFRACT;
     395                         } else if (prec == -1)
     396                                 prec = DEFPREC;


     634 #ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
     635                 /* trailing f.p. zeroes */
     636                 PAD(fpprec, zeroes);
     637                 ret += fpprec;
     638 #endif

now, I comment out as following, but it's not smart.
     391                         if (prec > MAXFRACT) {
     392                         /*
     393                                 if ((ch != 'g' && ch != 'G') || 
(flags&ALT))
     394                                         fpprec = prec - MAXFRACT;
     395                                 prec = MAXFRACT;
     396                         */
     397                         } else if (prec == -1)
     398                                 prec = DEFPREC;

thank you,
-- 
http://www.sinby.com/
Suzuki,Ryouzaburou
ryos@sinby.com


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