Fortran has good facilities for processing numbers. Arithmetic expressions and assignment statements can include integer, real, double precision, or complex items. Data type conversions are provided automatically when necessary; type conversions can also be performed explicitly using intrinsic functions. Other intrinsic functions are available for trigonometry, logarithms, and other useful operations.
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