http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49010

           Summary: Result of MOD and MODULO intrinsic has wrong sign
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: thenl...@users.sourceforge.net


If the first argument to the MOD and MODULO intrinsic is negative, and the
magnitude of the result is zero, the function returns a negative zero.

Fortran 2003/2008:
MOD: The value of the result is A − INT (A/P) * P.
MODULO: The value of the result is A − FLOOR (A / P) * P.

The values returned by these intrinsics should be the same as the expressions
by which the functions are defined; which is zero, without a negative sign.

Example:
program test_mod
    real :: a, p

    a = -4.0
    p = 2.0
    print *, mod(a, p), a - int(a / p) * p ! -0 0 expected 0 0
    print *, modulo(a, p), a - floor(a / p) * p ! -0 0 expected 0 0
end program test_mod

Reply via email to