Re: Leading zero for printing real numbers
- From: robert.corbett@xxxxxxx
- Date: Wed, 27 May 2009 19:25:00 -0700 (PDT)
On May 26, 11:44 am, glen herrmannsfeldt <g...@xxxxxxxxxxxxxxxx>
wrote:
Leslie Ballentine <balle...@xxxxxx> wrote:
< robert.corb...@xxxxxxx wrote:
< : On May 20, 7:18 am, Beliavsky <beliav...@xxxxxxx> wrote:
< :> write (*,"(f0.3)") 0.123
(snip, gives)
< :> .123
(snip)
< I am shocked to read that the pronted format ".123",
< withoout the leading zero is STANDARD CONFORMING!
< When I was in engineering school, we were instructed that
< there must always be at least one digit to the left of the
< decimal point.
Well, f0.3 is supposed to give the minimum number of digits.
I do note, though, that in C, at least on the version of gcc I tried,
%0.3f gives 0.123.
I wonder if it is too late to change the standard.
It is too late. The feature was present in the
Fortran 95 standard. An interpretation that allowed
the leading zero might have been possible, but I
doubt that the committee will change its opinion so
soon after issuing an official interpretation.
I changed my mind regarding the new edit descriptor
I proposed. I prefer adding two new control edit
descriptors, LN and LZ, instead. The edit descriptor
LZ would require the leading zero in this case and
would rquire the optional leading zeros to be produced.
The edit descriptor LN would prohibit the leading zero
in this case (the behavior required by the standard)
and would prohibit the optional leading zeros from
being produced.
Bob Corbett
.
- References:
- Leading zero for printing real numbers
- From: Beliavsky
- Re: Leading zero for printing real numbers
- From: robert . corbett
- Re: Leading zero for printing real numbers
- From: Leslie Ballentine
- Re: Leading zero for printing real numbers
- From: glen herrmannsfeldt
- Leading zero for printing real numbers
- Prev by Date: Re: unsigned integer
- Next by Date: Re: unsigned integer
- Previous by thread: Re: Leading zero for printing real numbers
- Next by thread: Re: Leading zero for printing real numbers
- Index(es):
Relevant Pages
|