Manual Reference Pages  - spacing (3fortran)

NAME

SPACING(3) - [MODEL_COMPONENTS] Smallest distance between two numbers of a given type

SYNOPSIS

result = spacing(x)

         elemental real(kind=KIND) function spacing(x)

real(kind=KIND), intent(in) :: x

CHARACTERISTICS

o X is type real of any valid kind
o The result is of the same type as the input argument X.

DESCRIPTION

SPACING(3) determines the distance between the argument X and the nearest adjacent number of the same type.

OPTIONS

o X : Shall be of type real.

RESULT

If X does not have the value zero and is not an IEEE infinity or NaN, the result has the value nearest to X for values of the same type and kind assuming the value is representable.

Otherwise, the value is the same as TINY(X). + zero produces TINY(X) + IEEE Infinity produces an IEEE Nan + if an IEEE NaN, that NaN is returned

If there are two extended model values equally near to X, the value of greater absolute value is taken.

EXAMPLES

Sample program:

    program demo_spacing
    implicit none
    integer, parameter :: sgl = selected_real_kind(p=6, r=37)
    integer, parameter :: dbl = selected_real_kind(p=13, r=200)

write(*,*) spacing(1.0_sgl) write(*,*) nearest(1.0_sgl,+1.0),nearest(1.0_sgl,+1.0)-1.0

write(*,*) spacing(1.0_dbl) end program demo_spacing

Results:

Typical values ...

         1.1920929E-07
          1.000000      1.1920929E-07
         0.9999999     -5.9604645E-08
         2.220446049250313E-016

STANDARD

Fortran 95

SEE ALSO

DIGITS(3), EPSILON(3), EXPONENT(3), FRACTION(3), HUGE(3), MAXEXPONENT(3), MINEXPONENT(3), NEAREST(3), PRECISION(3), RADIX(3), RANGE(3), RRSPACING(3), SCALE(3), SET_EXPONENT(3), TINY(3)

fortran-lang intrinsic descriptions (license: MIT) @urbanjost


Nemo Release 3.1 spacing (3fortran) April 28, 2024
Generated by manServer 1.08 from 509f764f-c017-4f69-b63f-1d289a4cc2fb using man macros.