Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Sep 2004 12:36:40 -0700
From:      Steve Kargl <sgk@troutmask.apl.washington.edu>
To:        freebsd-standards@freebsd.org
Subject:   is printf() broken?
Message-ID:  <20040905193640.GA37190@troutmask.apl.washington.edu>

next in thread | raw e-mail | index | archive | help
The following program

#include <stdio.h>
int main(void) {
	int d;
	double x;
	x = 1.234E05;
	for (d = 0; d < 5; d++)
    	printf("%+-31.*e\n", d, x);
	return 0;
}

generates

+1e+05                         
+1.2e+05                       
+1.23e+05                      
+1.234e+05                     
+1.2340e+05                    

The question is whether the first number should be
"+1.e+05".  That is, is the printing of the decimal
point required or optional?  I only have Harbison
and Steele's book and it does not state what the 
expected behavior should be.

-- 
Steve



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040905193640.GA37190>