Re: format with G descriptor




What happens when you don't obey to the standard depends on the
compiler.
Try e.g with "g10.0" and it will work - or way not with
"read(s,*) r" if you are using Fortran 90/95 or later,

Cut from one manual:

The full descripor is: Gw.d[Ee] where

w is the field width
m is the minimum number of digits that must be in the field
(including zeros).
d is the number of digits to the right of the decimal point
E is the exponent field
e is the number of digits in the exponent
Rules for Input Processing

On input, the G data edit descriptor transfers w characters from
an external field and assigns their real value to the
corresponding I/O list item. The G descriptor interprets and
assigns input data in the same way as the F data edit descriptor.

Rules for Input Processing

On input, the F data edit descriptor transfers w characters from
an external field and assigns their real value to the
corresponding I/O list item. The external field data must be an
integer or real constant.

If the input field contains only an exponent letter or decimal
point, it is treated as a zero value.

If the input field does not contain a decimal point or an
exponent, it is treated as a real number of w digits, with d
digits to the right of the decimal point. (Leading zeros are
added, if necessary.)

If the input field contains a decimal point, the location of that
decimal point overrides the location specified by the F
descriptor.

If the field contains an exponent, that exponent is used to
establish the magnitude of the value before it is assigned to the
list element.What a compiler does if you don't follow this might
be whatever it likes!

Kurt


Thanks for the detailed reply. I make a wrong assumpsion that the
code was ok since I didn't get any errors or warning from the
compiler.


Roman
.



Relevant Pages

  • Re: format with G descriptor
    ... m is the minimum number of digits that must be in the field. ... e is the number of digits in the exponent ... the G data edit descriptor transfers w characters from an external field and assigns their real value to the corresponding I/O list item. ...
    (comp.lang.fortran)
  • Re: BigNum -- Floating Point
    ... The 'N' is the number of decimal digits. ... The internal representation is really just a string of bits. ... the number of shifts for various multiples of ten: ... The 'exponent' is very closely related to ...
    (comp.programming)
  • Re: Another question about big floating point
    ... digits to the right of the radix point (so the numbers above have ... really add much cost to the addition/subtraction/etc. ... point when you use 2 as base for the exponent. ... shift plus the addition itself). ...
    (comp.programming)
  • Re: Newbye quetion: Why a double can store more number than a long ?
    ... > jose luis fernandez diaz wrote: ... You can divide the available 5 digits ... Say you use 2 digits for the exponent ... > sientific notation, are you?). ...
    (comp.lang.c)
  • Re: Newbye quetion: Why a double can store more number than a long ?
    ... > jose luis fernandez diaz wrote: ... You can divide the available 5 digits ... Say you use 2 digits for the exponent ... > sientific notation, are you?). ...
    (comp.lang.cpp)