aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/mod_sign0_1.f90
blob: 61ef5fd046c464a71a54383556cb263b3488a7bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
! { dg-do run }
! PR fortran/49010 
! MOD/MODULO sign of zero.

! We wish to provide the following guarantees:

! MOD(A, P): The result has the sign of A and a magnitude less than
! that of P.  

! MODULO(A, P): The result has the sign of P and a magnitude less than
! that of P.

! Here we test only with constant arguments (evaluated with
! mpfr_fmod), as we don't want to cause failures on targets with a
! crappy libm. But, a target where fmod follows C99 Annex F is
! fine. Also, targets where GCC inline expands fmod (such as x86(-64))
! are also fine.
program mod_sign0_1
  implicit none
  real :: r, t

  r = mod (4., 2.)
  t = sign (1., r)
  if (t < 0.) call abort

  r = modulo (4., 2.)
  t = sign (1., r)
  if (t < 0.) call abort

  r = mod (-4., 2.)
  t = sign (1., r)
  if (t > 0.) call abort

  r = modulo (-4., 2.)
  t = sign (1., r)
  if (t < 0.) call abort

  r = mod (4., -2.)
  t = sign (1., r)
  if (t < 0.) call abort

  r = modulo (4., -2.)
  t = sign (1., r)
  if (t > 0.) call abort

  r = mod (-4., -2.)
  t = sign (1., r)
  if (t > 0.) call abort

  r = modulo (-4., -2.)
  t = sign (1., r)
  if (t > 0.) call abort

end program mod_sign0_1