Liste des Groupes | Revenir à c arch |
Tim Rentsch <tr.17687@z991.linuxsc.com> schrieb:
>If the loop variable>
represents degrees C or F, or some other naturally signed measure it
should be signed (or maybe floating point).
The first one is a bad idea because temperature is a continuous
physical quantity.
The second has bad implications for constructs like
>
DO R = 0.0, 1.0, 0.1
>
where it will depend on details floating point arithmetic if the
number of loop trips is 10 or 11.
>
You can argue that people can write
>
DO R=0.0, 1.05, 0.1
>
but this construct was error-prone enough that it was deleted
from the Fortran standards.
>What kind of loop it>
is, whether ascending or descending, or what the increment is, etc,
is secondary; a more important factor is what sort of value is
being represented, and in almost all cases that is what should
determine the type used.
Not for floating point numbers. For that, you should simply do
>
DO I=0,10
R = I * 0.1
>
or
>
R = 0.0
DO I=0,10
...
R = R + 0.1
END DO
>
whichever rounding error you prefer.
Les messages affichés proviennent d'usenet.