[gecode-users] modulo with negative operators

Guido Tack tack at gecode.org
Thu Dec 9 00:26:07 CET 2010


Marco Correia wrote:

> hi,
> 
> Do you agree that 
> 
> -7 mod 12 == 5
> 
> ?
> 
> I'm asking because I know mod arithmetic can be tricky. Python says that this 
> is true, but gecode is failing on this constraint.
> 
> I'm not a gecode expert so probably I'm doing something wrong. I'm attaching a 
> small test case.

There's two different definitions of division and modulo. Python uses one, and C/C++/Java etc use another. Gecode uses the C++ definition, where -7%12==-7.

Cheers,
	Guido

-- 
Guido Tack, http://people.cs.kuleuven.be/~guido.tack/






More information about the users mailing list