REAL type

Standard: (F77) F90 F95 F2003 F2008 F2018 Example program


<Syntax>

REAL [ ( [ KIND= ] expression ) ]
DOUBLE PRECISION

The expression must be a scalar integer constant expression whose value identifies a valid kind of real.

REAL*2
REAL*4
REAL*8
REAL*16

<Semantics>

REAL declares entities (variables, functions, etc.) to be floating-point numbers. The KIND number determines the precision and exponent range of the numbers. The F90_KIND module contains named constants REAL16, REAL32, REAL64 and REAL128 which are convenient for specifying Reals with a particular size. The standard intrinsic module ISO_FORTRAN_ENV also contains those constants.

The SELECTED_REAL_KIND intrinsic function can be used to select a real kind based on decimal precision and exponent range requirements. The IEEE_SELECTED_REAL_KIND function in the standard intrinsic module IEEE_ARITHMETIC can also be used to select an ISO/IEC/IEEE 60559 conformant real kind.

The actual kind numbers used depend on whether “sequential”, “byte” or “unique” kind numbering is being used.

Sequential Kind Numbering (default)

KIND 16 1 2 3
Name REAL16 REAL32 REAL64 REAL128
Precision 3 6 15 30

Byte Kind Numbering (-kind=byte option)

KIND 2 4 8 16
Name REAL16 REAL32 REAL64 REAL128
Precision 3 6 15 30

Unique Kind Numbering (-kind=unique option)

KIND 304 301 302 303
Name REAL16 REAL32 REAL64 REAL128
Precision 3 6 15 30

REAL*2, REAL*4, REAL*8 and REAL*16 are synonyms for REAL(REAL16), REAL(REAL32), REAL(REAL64) and REAL(REAL128) respectively. These synonyms are not standard Fortran.

<Related>

CHARACTER type, COMPLEX type, Component Definition statement, DBLE intrinsic function, DIGITS intrinsic function, DOUBLE PRECISION type specifier, HUGE intrinsic function, IMPLICIT statement, INTEGER type, KIND intrinsic function, LOGICAL type, MAXEXPONENT intrinsic function, MINEXPONENT intrinsic function, PRECISION intrinsic function, RADIX intrinsic function, RANGE intrinsic function, REAL intrinsic function, SELECTED_REAL_KIND intrinsic function, Type Declaration statement