RANGE intrinsic function
Standard: F77 F90 F95 F2003 F2008
 Example Program

X : scalar or array of type Integer, Real or Complex;

Result : scalar Integer, default kind.

This function returns the decimal exponent range of variables with the same type and kind as X.

For type Integer, this is equal to INT(LOG10(REAL(HUGE(X)))); integers with RANGE(X) or fewer digits can all be represented in Integer variables with the same kind as X, but not all variables with RANGE(X)+1 digits can be represented.

For Real, this is equal to INT(MIN(LOG10(HUGE(X)),-LOG10(TINY(X)))); all powers of ten in the range 10.0**(-RANGE(X)) to 10.0**RANGE(X) can be approximated by Real variables with the same kind as X.

For Complex, it is equal to RANGE(REAL(X)) or RANGE(AIMAG(X)) i.e. the range of the real and imaginary parts.

Note that attempting to exceed the decimal range of a type may result in overflow. For Real or Complex, by default this will terminate the program with an error message; for Integer, there is a runtime checking option (−C=intovf) which can detect this error.

This is an inquiry function, so X need not be defined; indeed, it is permitted to be an unallocated allocatable or a disassociated or undefined pointer.

HUGE intrinsic function, INTEGER type, REAL type, SELECTED_INT_KIND intrinsic function, SELECTED_REAL_KIND intrinsic function, TINY intrinsic function.