subroutine Print_Ulp4(x0)
use ulp4816

INTERFACE ULP
MODULE PROCEDURE ulp4, ulp8, ulp16
END INTERFACE

real(4) x0(3), x, x1, x2
real(4) ULPx, ULP_ant

integer width, ex
!character(5) gr(2), eg(2), lt(2)


99 format(45(1H-))

write(1,*)
write(1, '(t3,a, t19,a, t33,a)') ' x', 'EXPONENT', 'ULP(x)';

ULP_ant =0.
DO x =x0(1), x0(2), x0(3)   !xStart, xEnd, xStep

ULPx =ULP(x)    ! ULP(x) =smallest add to 'x' ?
x1 =x +ULPx
x2 =x +ULPx/2.


if(ULPx /=ULP_ant) then
write(1, 99)
endif


ex =exponent(x)-1
if(x ==0.0) ex =-126
iwe =width(ex)
!write(1, '(/,1pE16.7, t22,I<iwe>, t32,1pE14.7)')  x, exponent(x)-1, ULPx;
write(1, '(/,1pE16.7, t22,I<iwe>, t32,1pE14.7)')  x, ex, ULPx;

write(1,*)
if(x1 >x) then
write(1, '(t3,a, \)') gr(1)
elseif(x1 ==x) then
write(1, '(t3,a, \)') eg(1)

else
write(1,'(t3,a, \)') lt(1)
endif

if(x2 ==x) then
write(1, *) ';  '//eg(2)
elseif(x2 >x) then
write(1, '(a, 1pE14.7)') ';  '//gr(2)//'!   x2 =', x2
endif

ULP_ant =ULPx
ENDDO

END
!------------------------------------------
subroutine Print_Ulp8(x0)
use ulp4816

INTERFACE ULP
MODULE PROCEDURE ulp4, ulp8, ulp16
END INTERFACE

real(8) x0(3), x, x1, x2
real(8) ULPx, ULP_ant

integer width, ex


99 format(61(1H-))

write(1,*)
write(1, '(t3,a, t26,a, t39,a)') ' x', 'EXPONENT', 'ULP(x)';

ULP_ant =0.
DO x =x0(1), x0(2), x0(3)   !xStart, xEnd, xStep

ULPx =ULP(x)	! ULP(x) =smallest add to 'x' ?
x1 =x +ULPx
x2 =x +ULPx/2.


if(ULPx /=ULP_ant) then
write(1, 99)
endif

ex =exponent(x)-1
if(x ==0.0) ex =-126
iwe =width(ex)
!write(1, '(/,1pE24.16, t29,I<iwe>, t38,1pE23.16)')  x, exponent(x)-1, ULPx;
write(1, '(/,1pE24.16, t29,I<iwe>, t38,1pE23.16)')  x, ex, ULPx;

write(1,*)
if(x1 >x) then
write(1, '(t3,a, \)') gr(1)
elseif(x1 ==x) then
write(1, '(t3,a, \)') eg(1)

else
write(1,'(t3,a, \)') lt(1)
endif

if(x2 ==x) then
write(1, *) ';  '//eg(2)
elseif(x2 >x) then
write(1, '(a, 1pE23.16)') ';  '//gr(2)//'!   x2 =', x2
endif

ULP_ant =ULPx
ENDDO

END
!-------------------------------------
subroutine Print_Ulp16(x0)
use ulp4816

INTERFACE ULP
MODULE PROCEDURE ulp4, ulp8, ulp16
END INTERFACE

real(16) x0(3), x, x1, x2
real(16) ULPx, ULP_ant

integer width, ex


99 format(89(1H-))

write(1,*)
write(1, '(t3,a, t40,a, t50,a)') ' x', 'EXPONENT', 'ULP(x)';

ULP_ant =0.
DO x =x0(1), x0(2), x0(3)   !xStart, xEnd, xStep

ULPx =ULP(x)	! ULP(x) =smallest add to 'x' ?
x1 =x +ULPx
x2 =x +ULPx/2.


if(ULPx /=ULP_ant) then
write(1, 99)
endif

ex =exponent(x)-1
if(x ==0.0) ex =-126
iwe =width(ex)
!write(1, '(/,1pD40.34, t44,I<iwe>, t50,1pD40.34)')  x, exponent(x)-1, ULPx;
write(1, '(/,1pD40.34, t44,I<iwe>, t50,1pD40.34)')  x, ex, ULPx;

write(1,*)
if(x1 >x) then
write(1, '(t3,a, \)') gr(1)
elseif(x1 ==x) then
write(1, '(t3,a, \)') eg(1)

else
write(1,'(t3,a, \)') lt(1)
endif

if(x2 ==x) then
write(1, *) ';  '//eg(2)
elseif(x2 >x) then
write(1, '(a, 1pD40.34)') ';  '//gr(2)//'!   x2 =', x2
endif

ULP_ant =ULPx
ENDDO

END
