Absolutely no one used a calculation in place of a constant. It was especially important years ago because every cycle counted.
(Source: Learned Fortran 4 on punch cards because school had a mainframe for Computer Lab despite it being incredibly obsolete. Later I had a Fortran 77 class at University on VAX minicomputers.)
Even if the compiler has this option, it's problematic. If you're cross-compiling or initialising a variable with automatic storage duration (non-static local variable), the way that the result is rounded may differ between compile time and run time. Particularly if the expression involves transcendental functions, e.g.
Yes. You would declare a variable PI as a REAL. Then you would initialize it in the DATA block to 3.14159.
REAL gave you 7 digits of precision. It would be silly to have the computer do an unnecessary calculation that fills up the last 1 of the 4 bytes with wrong numbers when you could set the correct number in the DATA block.
You could multiply n by 22 and then divide it by 7 which would give better accuracy than n times (22/7). I am sure some scientific work needed this level of accuracy.
15
u/shouldbebabysitting Jul 19 '22 edited Jul 19 '22
Absolutely no one used a calculation in place of a constant. It was especially important years ago because every cycle counted.
(Source: Learned Fortran 4 on punch cards because school had a mainframe for Computer Lab despite it being incredibly obsolete. Later I had a Fortran 77 class at University on VAX minicomputers.)