** Next:** Kind Functions
** Up:** Parametrised Intrinsic Types
** Previous:** Parametrised Integers
** Contents**

`Since a floating point number is represented by mantissa and exponent,
we need to select two parameters
`

- P
- the precision, giving
the number of decimal digits allowed in the mantissa, and
- R
- the range of the decimal exponent.

`The selector function
`

selected_real_kind(P=7, R=12)

`
returns a kind value that supports numbers with 7 decimal digits and
exponent magnitudes in the range
.
`
`Consider the following declarations
`

integer, parameter :: single = selected_real_kind(p=6, r=37), &
double = selected_real_kind(p=14,r=307), &
quad = selected_real_kind(p=33,r=4931)
real(kind=single) :: x
real(kind=double) :: y
real(kind=quad) :: z

`
On an Alpha 21264 processor the kind values are ``single` = 4,
`double` = 8, `quad` = 16. The variables `x`, `y`, `z`
are of type `REAL`, but have different kinds; using parametrized
declarations we can work at the level of accuracy desired. Since
the kinds `single`, `double` and `quad` are defined via
the selector function, we can count on the precision and range desired,
regardless of the machine. The code is therefore portable.

Adrian Sandu
2001-08-26