2014-01-30 Alangi Derick <alangiderick@gmail.com>
[official-gcc.git] / gcc / testsuite / gfortran.dg / mod_sign0_1.f90
blob61ef5fd046c464a71a54383556cb263b3488a7bc
1 ! { dg-do run }
2 ! PR fortran/49010
3 ! MOD/MODULO sign of zero.
5 ! We wish to provide the following guarantees:
7 ! MOD(A, P): The result has the sign of A and a magnitude less than
8 ! that of P.
10 ! MODULO(A, P): The result has the sign of P and a magnitude less than
11 ! that of P.
13 ! Here we test only with constant arguments (evaluated with
14 ! mpfr_fmod), as we don't want to cause failures on targets with a
15 ! crappy libm. But, a target where fmod follows C99 Annex F is
16 ! fine. Also, targets where GCC inline expands fmod (such as x86(-64))
17 ! are also fine.
18 program mod_sign0_1
19 implicit none
20 real :: r, t
22 r = mod (4., 2.)
23 t = sign (1., r)
24 if (t < 0.) call abort
26 r = modulo (4., 2.)
27 t = sign (1., r)
28 if (t < 0.) call abort
30 r = mod (-4., 2.)
31 t = sign (1., r)
32 if (t > 0.) call abort
34 r = modulo (-4., 2.)
35 t = sign (1., r)
36 if (t < 0.) call abort
38 r = mod (4., -2.)
39 t = sign (1., r)
40 if (t < 0.) call abort
42 r = modulo (4., -2.)
43 t = sign (1., r)
44 if (t > 0.) call abort
46 r = mod (-4., -2.)
47 t = sign (1., r)
48 if (t > 0.) call abort
50 r = modulo (-4., -2.)
51 t = sign (1., r)
52 if (t > 0.) call abort
54 end program mod_sign0_1