next up previous contents index
Next: Double Precision Constants Up: Constants Previous: Integer Constants

Real Constants

  A real constant must contain a decimal point or an exponent (or both) to distinguish it from one of integer type. The letter ``E" is used in Fortran to represent ``times 10 to the power of". For example, the constant $1.234 \times 10^{-5}$ is written as ``1.234E-5".

The most general form of a real constant is:

sign digits . digits E sign digits
2c-integer-part- 2c-decimal-part-   2c-exponent-      
4c--basic-real-constant-- 3c--exponent-section--          
Both signs are optional; a plus sign is assumed if no sign is present. Leading zeros in the integer-part and in the exponent are ignored. Either the integer part or the decimal part may be omitted if it is zero but one or the other must be present. If the value of the exponent is zero the entire exponent section may be omitted provided a decimal point is present in the number.

There is no harm in giving more decimal digits in a real (or double precision) constant than the computer can make use of: the value will be correctly rounded by the computer and the extra decimal places ignored.

Here are a few examples of valid real constants:
.5 -10. 1E3 +123.456E4 .000001
Dangling decimal points, though permitted, are easily overlooked, and it is conventional to standardize constants in exponential notation so that there is only one digit before the decimal point. Using this convention, these values would look like this:
0.5 -10.0 1000.0 1.23456E6 1.0E-6


next up previous contents index
Next: Double Precision Constants Up: Constants Previous: Integer Constants
Helen Rowlands
8/27/1998