real(4) function ULP4(x)
use comun

real(4) x       !, xn_min, xs_min

!xn_min =2.0**Emin   ! 2^-126
!xs_min =2.0**(Emin-P+1) ! 2^-149

if( abs(x) >=xn_min) then   ! normal
ULP4 =2.0**(exponent(x) -P)

else    ! 0.0 or sub-normal
ULP4 =xs_min
endif
end function ULP4
!--------------------------------

real(8) function ULP8(x)
use comun

real(8) x       !, xn_min8, xs_min8

!xn_min8 =2.D0**Emin8   !
!xs_min8 =2.D0**(Emin8-P8+1) !

if( dabs(x) >=xn_min8) then   ! normal
ULP8 =2.D0**(exponent(x) -P8)

else    ! 0.D0 OR sub-normal
ULP8 =xs_min8
endif
end function ULP8
!---------------------------------

real(16) function ULP16(x)
use comun

real(16) x  !, xn_min16, xs_min16

!xn_min16 =2.q0**Emin16   !
!xs_min16 =2.q0**(Emin16-P16+1) !

if( qabs(x) >=xn_min16) then   ! normal
ULP16 =2.q0**(exponent(x) -P16)

else    ! 0.q0 OR sub-normal
ULP16 =xs_min16
endif
end function ULP16
