DCL: MATH1: Summary: FORTRAN77 Standard
Here is a list of items besides those in the previous sections to take note of when writing programs in FORTRAN.
In most systems, no warning is given when there is integer overflow, and the program will continue with the calculation by simply rounding down the higher-order digits..
This is extremely hazardous to the user, but in programs that generate random numbers, overflows are sometimes caused intentionally.
In any case, the user should be careful when handling large integers.
When floating-point numbers are assigned to integer variables, the part below the decimal point is rounded down but it is done so as to make the value "nearer to 0." For a positive number, this is the same as the rounding down procedure in mathematics, but it works in the opposite direction for a negative number. (When -1.5 is rounded down in FORTRAN, it becomes -1.) Similarly, the intrinsic function MOD also has a different definition for negative numbers compared to the mathematical definition of remainder.
When the user wants to perform rounding down and calculation of remainders in the mathematical sense, use the FNCLIB or the INTLIB routines.
In the exponentiation calculation X = B**N, the round-off error of the base B appears with a fivefold increase. Therefore, for large N, the round-off error alone will result in large error. Furthermore, when the error generated in the calculation process is added to this, the resulting error may become unacceptably large. And to make matters worse, the amount of error produced is not the same for different implementations.
When there is a problem with precision in exponentiation, safety measures should be taken such as to use double-precision arithmetic for that part. One should especially give close attention to the precision of the base B, because for example, there is no guarantee that the same precision achieved on one computer can be achieved on another..
The FORTRAN standard states that "a constant is determined by the character string and the value representing it." Therefore, not only the value but also the precision of the constant is determined by how the constant is defined. For example, when a constant is defined byDOUBLE PRECISION X .... X = 3.8*X*(1.-X) ....which uses single-precision values 3.8 and 1, the precision of the double-precision calculation is not achieved as a whole. To be precise, the constant 3.8 is converted into a double-precision floating-point number before multiplication with X. However, the value of the double-precision floating-point number remains the single-precision 3.8, and is not equal to the double-precision value of 3.8D0. In the above case, the following expression should always be used.
X = 3.8D0*X*(1.D0-X)This is also true for constants in DATA statements.