1 ! Test that NINT gives right results even in corner cases
4 ! http://gcc.gnu.org/ml/fortran/2005-04/msg00139.html
7 ! { dg-xfail-run-if "PR 33271, math library bug" { powerpc-ibm-aix* powerpc-*-linux* powerpc64-*-linux* *-*-mingw* } { "-O0" } { "" } }
8 ! Note that this doesn't fail on powerpc64le-*-linux*.
10 integer(kind
=8) :: i1
, i2
14 a
= nearest(0.5_8
,-1.0_8
)
15 i2
= nint(nearest(0.5_8
,-1.0_8
))
17 if (i1
/= 0 .or
. i2
/= 0) call abort
22 if (i1
/= 1 .or
. i2
/= 1) call abort
24 a
= nearest(0.5_8
,1.0_8
)
25 i2
= nint(nearest(0.5_8
,1.0_8
))
27 if (i1
/= 1 .or
. i2
/= 1) call abort
30 j2
= nint(nearest(0.5,-1.0))
32 if (j1
/= 0 .or
. j2
/= 0) call abort
37 if (j1
/= 1 .or
. j2
/= 1) call abort
40 j2
= nint(nearest(0.5,1.0))
42 if (j1
/= 1 .or
. j2
/= 1) call abort
44 a
= 4503599627370497.0_8
46 i2
= nint(4503599627370497.0_8
,kind
=8)
47 if (i1
/= i2
.or
. i1
/= 4503599627370497_8) call abort
49 a
= -4503599627370497.0_8
51 i2
= nint(-4503599627370497.0_8
,kind
=8)
52 if (i1
/= i2
.or
. i1
/= -4503599627370497_8) call abort