From: ceriel Date: Wed, 11 Feb 1987 12:47:45 +0000 (+0000) Subject: when printing floats in "e"-format, trailing zeros are significant! X-Git-Tag: release-5-5~4683 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=f18da9078cd54d2ad021ab8512f4c8bcbcb4b55a;p=ack.git when printing floats in "e"-format, trailing zeros are significant! --- diff --git a/lang/basic/lib/print.c b/lang/basic/lib/print.c index a335f968d..16c48598e 100644 --- a/lang/basic/lib/print.c +++ b/lang/basic/lib/print.c @@ -31,25 +31,31 @@ _str(f,buffer) double f; char *buffer; { - char *c; - c= buffer; + register char *c = buffer; + int eformat = 0; if( f>=0){ - if( f> 1.0e8) + if( f> 1.0e8) { + eformat = 1; sprintf(buffer," %e",f); + } else sprintf(buffer," %f",f); c++; }else { - if(-f> 1.0e8) + if(-f> 1.0e8) { + eformat = 1; sprintf(buffer,"-%e",-f); + } else sprintf(buffer,"-%f",-f); } - for( ; *c && *c!= ' ';c++) ; - c--; - while( c>buffer && *c== '0') - { - *c= 0;c--; + if (! eformat) { + for( ; *c && *c!= ' ';c++) ; + c--; + while( c>buffer && *c== '0') + { + *c= 0;c--; + } + if( *c=='.') *c=0; } - if( *c=='.') *c=0; strcat(buffer," "); } _prfnum(f)