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


X : Real with any kind;

Result : same type and kind as X.


This function returns the spacing of model numbers with the same kind as X, in the vicinity of X. If X is not a model number (for example, if X is an IEEE subnormal number), SPACING is the value for the nearest model number to X; if X is an IEEE infinity or NaN, the result is a NaN.

For nonzero finite numbers, this is equal to REAL(RADIX(X),KIND(X))**MAX(EXPONENT(X)-DIGITS(X),MINEXPONENT(X)-1). Note that the spacing of model numbers in the vicinity of zero is TINY(X).

Like many intrinsic functions, this is elemental; the result has the same shape as X, with the operation being applied elementwise.

DIGITS intrinsic function, RADIX intrinsic function, EXPONENT intrinsic function, MINEXPONENT intrinsic function, REAL type, RRSPACING intrinsic function, TINY intrinsic function.