This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: the "general" floating point format
- From: Ian Lance Taylor <ian at airs dot com>
- To: Anthony Shipman <als at iinet dot net dot au>
- Cc: gcc-help at gnu dot org
- Date: 01 Jan 2006 19:48:15 -0800
- Subject: Re: the "general" floating point format
- References: <200601011718.17237.als@iinet.net.au>
Anthony Shipman <als@iinet.net.au> writes:
> Is there a precise specification of how printf() decides whether to use the
> fixed point or scientific format when the format is "general"?
I assume you are referring to %g. The answer is yes. From the
GNU/Linux man page, for example (man 3 printf):
The double argument is converted in style f or e (or F or E for G
conversions). The precision specifies the number of significant
digits. If the precision is missing, 6 digits are given; if the
precision is zero, it is treated as 1. Style e is used if the
exponent from its conversion is less than -4 or greater than or
equal to the precision. Trailing zeros are removed from the
fractional part of the result; a decimal point appears only if it
is followed by at least one digit.
Ian