Re: Leading zero for printing real numbers



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


.



Relevant Pages

  • Re: The annotated annotated annotated C standard
    ... outside the Standard in order to achieve a platform-specific goal. ... mathematics found itself ... it is true that there are some cases where division by zero ...
    (comp.programming)
  • Re: The annotated annotated annotated C standard
    ... outside the Standard in order to achieve a platform-specific goal. ... mathematics found itself ... it is true that there are some cases where division by zero ...
    (comp.programming)
  • Re: Requesting advice how to clean up C code for validating string represents integer
    ... Linkname: c standard - clc-wiki ... with a signed zero (including all IEC 60559 implementations) ... that follow the specification of annex G, the sign of zero ... between brake pedal and brake pads being through a complicated ...
    (comp.lang.c)
  • Re: NULL and zeros
    ... The machine's bizarre internal representation does not excuse the implementation from its obligations. ... standard. ... The standard indeed does not specify what an "all bytes zero" or "all ... the originator of this calloc() is clueless -- my personal ...
    (comp.lang.c)
  • Re: A dead subject
    ... >> made the formula easier, ... > BTW - how many subtractions are required to transform my standard ... Some are already set equal to zero and MOST are not. ... think it is about time that mathematicians stop worshipping zero. ...
    (sci.math)