RANGE(3) - [MODEL:NUMERIC] Decimal exponent range of a numeric kind
result = range(x)
integer function range (x)TYPE(kind=KIND),intent(in) :: x
o X may be of type integer, real, or complex. It may be a scalar or an array. o KIND is any kind supported by the type of X o the result is a default integer scalar
RANGE(3) returns the decimal exponent range in the model of the type of X.
Since X is only used to determine the type and kind being interrogated, the value need not be defined.
o X : the value whose type and kind are used for the query
Case (i) : For an integer argument, the result has the value
int (log10 (huge(x)))Case (ii) : For a real argument, the result has the value
int(min (log10 (huge(x)), -log10(tiny(x) )))Case (iii) : For a complex argument, the result has the value
range(real(x))
Sample program:
program demo_range use,intrinsic :: iso_fortran_env, only : dp=>real64,sp=>real32 implicit none real(kind=sp) :: x(2) complex(kind=dp) :: y print *, precision(x), range(x) print *, precision(y), range(y) end program demo_rangeResults:
> 6 37 > 15 307
Fortran 95
DIGITS(3), EPSILON(3), EXPONENT(3), FRACTION(3), HUGE(3), MAXEXPONENT(3), MINEXPONENT(3), NEAREST(3), PRECISION(3), RADIX(3), RRSPACING(3), SCALE(3), SET_EXPONENT(3), SPACING(3), TINY(3)
Fortran intrinsic descriptions (license: MIT) @urbanjost
Nemo Release 3.1 | range (3fortran) | November 02, 2024 |