Exemple #1
0
 def arith_remainder_same(self, other):
     from rpython.rlib.rbigint import _divrem
     assert isinstance(other, values.W_Bignum)
     try:
         div, rem = _divrem(self.value, other.value)
         return values.W_Integer.frombigint(rem)
     except ZeroDivisionError:
         raise Exception("zero_divisor")
Exemple #2
0
 def arith_remainder_same(self, other):
     from rpython.rlib.rbigint import _divrem
     assert isinstance(other, values.W_Bignum)
     try:
         div, rem = _divrem(self.value, other.value)
         return values.W_Integer.frombigint(rem)
     except ZeroDivisionError:
         raise Exception("zero_divisor")
Exemple #3
0
 def arith_quotient_same(self, other):
     from rpython.rlib.rbigint import _divrem # XXX make nice interface
     assert isinstance(other, values.W_Bignum)
     x = self.value
     y = other.value
     try:
         div, rem = _divrem(x, y)
     except ZeroDivisionError:
         raise SchemeException("zero_divisor")
     return values.W_Integer.frombigint(div)
Exemple #4
0
 def arith_quotient_same(self, other):
     from rpython.rlib.rbigint import _divrem  # XXX make nice interface
     assert isinstance(other, values.W_Bignum)
     x = self.value
     y = other.value
     try:
         div, rem = _divrem(x, y)
     except ZeroDivisionError:
         raise SchemeException("zero_divisor")
     return values.W_Integer.frombigint(div)
Exemple #5
0
 def prim_remainder(self, right, universe):
     if isinstance(right, BigInteger):
         d, r = _divrem(rbigint.fromint(self._embedded_integer),
                        right.get_embedded_biginteger())
         return universe.new_biginteger(r)
     elif isinstance(right, Double):
         return self._to_double(universe).prim_remainder(right, universe)
     else:
         l = self._embedded_integer
         r = right.get_embedded_integer()
         return universe.new_integer(llop.int_mod(lltype.Signed, l, r))
Exemple #6
0
 def prim_remainder(self, right, universe):
     if isinstance(right, BigInteger):
         d, r = _divrem(rbigint.fromint(self._embedded_integer),
                        right.get_embedded_biginteger())
         return universe.new_biginteger(r)
     elif isinstance(right, Double):
         return self._to_double(universe).prim_remainder(right, universe)
     else:
         l = self._embedded_integer
         r = right.get_embedded_integer()
         return universe.new_integer(llop.int_mod(lltype.Signed, l, r))