Citation:
Bonjour,
essaye avec la classe java.math.BigInteger.(http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigInteger.html)
BigInteger b1 = new BigInteger("-1");
BigInteger b3 = new BigInteger("3");
int mod = b1.mod(b3).intValue(); // OU BigInteger mod = b1.mod(b3);
Cette classe n'a pas de constructeur qui accepte des "int" ou "long" ... mais tu peux faire un truc du genre :
int i1 = -1 ;
int i2 = 3 ;
BigInteger b1 = new BigInteger(new Integer(i1).toString());
BigInteger b3 = new BigInteger(new Integer(i2).toString());
int mod = b1.mod(b3).intValue();
Il y a peut-être plus simple, mais le résultat semble correct.
ed
(Exemple pour -1mod3)