🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Craig Chamberlain Tue, 22 Dec 1992 15:20
printf("%e", 0.0) prints with exponent e+01
#4
Author: Craig Chamberlain
Date: Tue, 22 Dec 1992 15:20
31 lines
1156 bytes
Why does the floating value 0.0 print with an exponent
of +01 in printf %e format?  It is printed as 0.000000e+00
on the DECstation and VAX.

/* printf_zero.c */

#include <stdio.h>


int
main (argc, argv)
int argc;
char *argv [];

{
  double dr1;


  dr1 = 0.0;
  printf("dr1 is %e  %f  %g\n", dr1, dr1, dr1);

} /* main */

$ cc/standard=vaxc/float=ieee_float printf_zero.c
$ link printf_zero
$ r printf_zero
dr1 is 0.000000e+01  0.000000  0
-- 
(My opinions do not necessarily represent those of my employer.)
Craig Chamberlain, Software Engineer, Applicon Schlumberger
Ann Arbor, Michigan  chamber@ann-arbor.applicon.slb.com  (313) 995-6310
Re: printf("%e", 0.0) prints with exponent e+01
#6
Author: Carl Fogelin
Date: Tue, 22 Dec 1992 17:54
39 lines
1462 bytes
In article 21980@ann-arbor.applicon.slb.com, chamber@mailhost.aa.cad.slb.com (Craig Chamberlain) writes:
>Why does the floating value 0.0 print with an exponent
>of +01 in printf %e format?  It is printed as 0.000000e+00
>on the DECstation and VAX.
>
>/* printf_zero.c */
>
>#include <stdio.h>
>
>
>int
>main (argc, argv)
>int argc;
>char *argv [];
>
>{
>  double dr1;
>
>
>  dr1 = 0.0;
>  printf("dr1 is %e  %f  %g\n", dr1, dr1, dr1);
>
>} /* main */
>
>$ cc/standard=vaxc/float=ieee_float printf_zero.c
>$ link printf_zero
>$ r printf_zero
>dr1 is 0.000000e+01  0.000000  0
>-- 

Now that's bizarre.  I looked up the fprintf's "e" format in the ANSI standard
and it states:

     4.9.6.1   "...  If the value is zero, the exponent is zero."

I think you need an answer from DEC.

Carl C. Fogelin                  "This is strictly my own opinion."
(fogelinc@cyanamid.com)
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads