1 !Program to test NEAREST intrinsic function.
4 real s
, r
, x
, y
, inf
, max
26 if (.not
. (x
.gt
. s
.and
. y
.lt
. s
)) call abort()
28 ! ??? This is pretty sketchy, but passes on most targets.
32 call test_up(max
, inf
)
33 call test_up(-inf
, -max
)
34 call test_down(inf
, max
)
35 call test_down(-max
, -inf
)
37 ! ??? Here we require the F2003 IEEE_ARITHMETIC module to
38 ! determine if denormals are supported. If they are, then
39 ! nearest(0,1) is the minimum denormal. If they are not,
40 ! then it's the minimum normalized number, TINY. This fails
41 ! much more often than the infinity test above, so it's
44 ! call test_up(0, min)
45 ! call test_up(-min, 0)
46 ! call test_down(0, -min)
47 ! call test_down(min, 0)
50 subroutine test_up(s
, e
)
54 if (x
.ne
. e
) call abort()
57 subroutine test_down(s
, e
)
61 if (x
.ne
. e
) call abort()
64 subroutine test_n(s1
, r
)
68 if (nearest(x
, -r
) .ne
. s1
) call abort()
70 if (nearest(x
, r
) .ne
. s1
) call abort()
74 if (nearest(x
, -r
) .ne
. s1
) call abort()
76 if (nearest(x
, r
) .ne
. s1
) call abort()