



Arithmetic For example, the well-known cosine formula for the third side of a triangle, given the other two sides and the angle between them is:
Translated into a Fortran expression it looks like this:
SQRT(B**2 + C**2 - 2.0 * B * C * COS(ANGLEA))
which makes use of the intrinsic functions SQRT and COS. Although SQRT(X) produces
the same result as X**0.5, the square-root function is simpler, faster, and probably
more accurate than raising to the power of one half, which would actually be carried
out using both the EXP and LOG functions.
Assignment statements evaluate an expression and assign its value to a variable (or array element). Unlike almost all other Fortran statements, they do not start with a keyword. For example:
A = SQRT(B**2 + C**2 - 2.0 * B * C * COS(ANGLEA)) TOTAL(N/2+1) = 0.0 FLUX = FLUX + 1.0 |
6.1 Arithmetic Expressions
6.2 Arithmetic Intrinsic Functions
6.3 Arithmetic Assignment Statements