Home > Archive > Fortran > June 2005 > 99. not 99.0
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| I'm reading a bunch of old fortran 77 code.
They do this:
VALMISSING=99.
instead of doing what i would consider to be more readable:
VALMISSING=99.0
Is there a reason for doing it without the trailing 0?
| |
| Richard E Maine 2005-06-08, 4:00 pm |
| In article <1118252519.569463.115440@g47g2000cwa.googlegroups.com>,
"Al" <allelopath@hotmail.com> wrote:
> I'm reading a bunch of old fortran 77 code.
> They do this:
> VALMISSING=99.
>
> instead of doing what i would consider to be more readable:
> VALMISSING=99.0
>
> Is there a reason for doing it without the trailing 0?
Purely personal style preference. Either way means exactly the same
thing. I'll not argue which preference is better; the choice is
personal.
--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain | experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
| |
| jamesgiles@att.net 2005-06-08, 8:58 pm |
|
Richard E Maine wrote:
> In article <1118252519.569463.115440@g47g2000cwa.googlegroups.com>,
> "Al" <allelopath@hotmail.com> wrote:
....
....[color=darkred]
> Purely personal style preference. Either way means exactly the same
> thing. I'll not argue which preference is better; the choice is
> personal.
Well as another frequent participant in this group often
says - for the purposes of comparison only, the Ada rule
is to require a digit both before and after the decimal
point. My own preprocessed language requires a digit
after the decimal point, but this isn't just a matter
of personal style (or, not with respect to this issue
anyway).
Fortran requires that defined operators not contain digits
or underscores. I don't know why it disallows underscores,
but disallowing digits has the purpose of eliminating a syntactic
difficulty. Consider:
A = 1.e5.{etc}
Where the {etc} consists of the remainder of the expression.
Now, if digits were allowed in operators, would the initial
token of the expression be the integer literal 1, or the real
literal 1.e5? You can't tell without further lookahead. So,
suppose the expression continues:
A = 1.e5.fcn.abc.{etc}
Well, you still can't identify whether the first token is an
integer literal 1 or a real literal 1.e5. In fact, you can
continue with such an expression to the limit of allowed
continuation lines before finally resolving the issue (the
last token must be an operand). This is unsuitable for
clean implementation, so Fortran disallows digit in defined
operators and can tell that 1.e5 must be the first token of
the above.
That leaves the problem that if you want your operators to
have a name that matches the function that's associated with
the operator, you can't always do it. Function names are
allowed to contain digits (and underscores). However, if the
rule is that real literal must always have a digit after the
decmal point, the above problem goes away and the rules for
defined operator names can be the same as the rules for normal
identifiers, enclosed in periods.
--
J. Giles
| |
| Dick Hendrickson 2005-06-08, 8:58 pm |
|
jamesgiles@att.net wrote:
>
> Richard E Maine wrote:
>
>
> ...
>
>
> ...
>
>
>
> Well as another frequent participant in this group often
> says - for the purposes of comparison only, the Ada rule
> is to require a digit both before and after the decimal
> point. My own preprocessed language requires a digit
> after the decimal point, but this isn't just a matter
> of personal style (or, not with respect to this issue
> anyway).
>
> Fortran requires that defined operators not contain digits
> or underscores. I don't know why it disallows underscores,
I think there is also an ambiguity with kind parameters,
possibly character ones where they lead the constant,
although I can't remember the case. Also, it might have
been easier to just say "alphabetic" rather than to prove
that there would never be any ambiguities if something
was extended in an unforseen way in the future.
Dick Hendrickson
| |
| Arjen Markus 2005-06-09, 8:57 am |
| Richard E Maine wrote:
>
> In article <1118252519.569463.115440@g47g2000cwa.googlegroups.com>,
> "Al" <allelopath@hotmail.com> wrote:
>
>
> Purely personal style preference. Either way means exactly the same
> thing. I'll not argue which preference is better; the choice is
> personal.
>
There is one more "objective" argument that I can think of (probably
because that is how I reationalise my preference):
In 99. it is easy to miss the decimal point, whereas in 99.0 it is
bracketed by two digits.
Regards,
Arjen
| |
|
|
"Al" <allelopath@hotmail.com> wrote in message
news:1118252519.569463.115440@g47g2000cwa.googlegroups.com...
> I'm reading a bunch of old fortran 77 code.
> They do this:
> VALMISSING=99.
>
> instead of doing what i would consider to be more readable:
> VALMISSING=99.0
>
> Is there a reason for doing it without the trailing 0?
One less keystroke.
Jim
>
|
|
|
|
|