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* *-*-mingw* } { "-O0" } { "" } }
9 integer(kind
=8) :: i1
, i2
13 a
= nearest(0.5_8
,-1.0_8
)
14 i2
= nint(nearest(0.5_8
,-1.0_8
))
16 if (i1
/= 0 .or
. i2
/= 0) call abort
21 if (i1
/= 1 .or
. i2
/= 1) call abort
23 a
= nearest(0.5_8
,1.0_8
)
24 i2
= nint(nearest(0.5_8
,1.0_8
))
26 if (i1
/= 1 .or
. i2
/= 1) call abort
29 j2
= nint(nearest(0.5,-1.0))
31 if (j1
/= 0 .or
. j2
/= 0) call abort
36 if (j1
/= 1 .or
. j2
/= 1) call abort
39 j2
= nint(nearest(0.5,1.0))
41 if (j1
/= 1 .or
. j2
/= 1) call abort
43 a
= 4503599627370497.0_8
45 i2
= nint(4503599627370497.0_8
,kind
=8)
46 if (i1
/= i2
.or
. i1
/= 4503599627370497_8) call abort
48 a
= -4503599627370497.0_8
50 i2
= nint(-4503599627370497.0_8
,kind
=8)
51 if (i1
/= i2
.or
. i1
/= -4503599627370497_8) call abort