RRSPACING(3) - [MODEL_COMPONENTS] Reciprocal of the relative spacing of a numeric type
result = rrspacing(x)
elemental real(kind=KIND) function rrspacing(x)real(kind=KIND),intent(in) :: x
o X is type real of any kind o The return value is of the same type and kind as X.
RRSPACING(3) returns the reciprocal of the relative spacing of model numbers near X.
o X : Shall be of type real.
The return value is of the same type and kind as X. The value returned is equal to ABS(FRACTION(X)) * FLOAT(RADIX(X))**DIGITS(X).
Sample program:
program demo_rrspacing implicit none integer, parameter :: sgl = selected_real_kind(p=6, r=37) integer, parameter :: dbl = selected_real_kind(p=13, r=200) character(len=*),parameter :: gen=(*(g0)), nl=new_line(A) real(kind=sgl) :: x x=-3.0_sgl print gen, & rrspacing(,x,_sgl)=, rrspacing(x), nl, & rrspacing(x)=abs(fraction(x))*float(radix(x))**digits(x), nl, & so this should be the same as rrspacing():, nl, & abs( fraction(x) ) * float( radix(x) )**digits(x), nl, & RRSPACING (-3.0) has the value 0.75x2**24 for reals, nl, & on current typical platforms. For reference:, nl, & 0.75*2**24=, 0.75*2**24, nl, & sign should not matter, so,rrspacing(x)==rrspacing(-x), nl, & note the kind of the value is significant, nl, & rrspacing(-3.0_dbl), nl, & for common platforms rrspacing(487923.3d0)=>, nl, & 8.382458680573952E+015, nl, & rrspacing(487923.3d0), nl, & end program demo_rrspacing> rrspacing(-3.00000000_sgl)=12582912.0 > rrspacing(x)=abs(fraction(x))*float(radix(x))**digits(x) > so this should be the same as rrspacing(): > 12582912.0 > RRSPACING (-3.0) has the value 0.75x2**24 for reals > on current typical platforms. For reference: > 0.75*2**24=12582912.0 > sign should not matter, soT > note the kind of the value is significant > 6755399441055744.0 > for common platforms rrspacing(487923.3d0)=>8.382458680573952E+015 > 8382458465825587.0
Fortran 90
DIGITS(3), EPSILON(3), EXPONENT(3), FRACTION(3), HUGE(3), MAXEXPONENT(3), MINEXPONENT(3), NEAREST(3), PRECISION(3), RADIX(3), RANGE(3), SCALE(3), SET_EXPONENT(3), SPACING(3), TINY(3)
Fortran intrinsic descriptions
Nemo Release 3.1 | rrspacing (3fortran) | November 02, 2024 |