selected_real_kind(p, r, radix)
return the kind value of a real data type with decimal precision of at least p
digits, exponent range of at least r
, and with a radix of radix
.
Fortran 95 and later; with radix
Fortran 2008 and later
Transformational function
result = selected_real_kind([p, r, radix])
p
- (Optional) shall be a scalar and of type integer
.r
- (Optional) shall be a scalar and of type integer
.radix
- (Optional) shall be a scalar and of type integer
.Before Fortran 2008, at least one of the arguments r
or p
shall be present; since Fortran 2008, they are assumed to be zero if absent.
selected_real_kind
returns the value of the kind type parameter of a real data type with decimal precision of at least p
digits, a decimal exponent range of at least r
, and with the requested radix
. If the radix
parameter is absent, real kinds with any radix can be returned. If more than one real data type meet the criteria, the kind of the data type with the smallest decimal precision is returned. If no real data type matches the criteria, the result is
p
, but the r
and radix
requirements can be fulfilledr
, but p
and radix
are fulfillableradix
but not p
and r
requirements are fulfillableradix
and either p
or r
requirements are fulfillableradix
program real_kinds
integer,parameter :: p6 = selected_real_kind(6)
integer,parameter :: p10r100 = selected_real_kind(10,100)
integer,parameter :: r400 = selected_real_kind(r=400)
real(kind=p6) :: x
real(kind=p10r100) :: y
real(kind=r400) :: z
print *, precision(x), range(x)
print *, precision(y), range(y)
print *, precision(z), range(z)
end program real_kinds