Exemplo n.º 1
0
 def unique_id(self, space):
     if self.user_overridden_class:
         return W_Object.unique_id(self, space)
     from pypy.rlib.longlong2float import float2longlong
     from pypy.objspace.std.model import IDTAG_COMPLEX as tag
     real = space.float_w(space.getattr(self, space.wrap("real")))
     imag = space.float_w(space.getattr(self, space.wrap("imag")))
     real_b = rbigint.fromrarith_int(float2longlong(real))
     imag_b = rbigint.fromrarith_int(float2longlong(imag))
     val = real_b.lshift(64).or_(imag_b).lshift(3).or_(rbigint.fromint(tag))
     return space.newlong_from_rbigint(val)
Exemplo n.º 2
0
 def immutable_unique_id(self, space):
     if self.user_overridden_class:
         return None
     from pypy.rlib.longlong2float import float2longlong
     from pypy.objspace.std.model import IDTAG_COMPLEX as tag
     real = space.float_w(space.getattr(self, space.wrap("real")))
     imag = space.float_w(space.getattr(self, space.wrap("imag")))
     real_b = rbigint.fromrarith_int(float2longlong(real))
     imag_b = rbigint.fromrarith_int(float2longlong(imag))
     val = real_b.lshift(64).or_(imag_b).lshift(3).or_(rbigint.fromint(tag))
     return space.newlong_from_rbigint(val)
Exemplo n.º 3
0
 def test_args_from_int(self):
     BASE = 1 << SHIFT
     assert rbigint.fromrarith_int(0).eq(rbigint([0], 0))
     assert rbigint.fromrarith_int(17).eq(rbigint([17], 1))
     assert rbigint.fromrarith_int(BASE - 1).eq(rbigint([BASE - 1], 1))
     assert rbigint.fromrarith_int(BASE).eq(rbigint([0, 1], 1))
     assert rbigint.fromrarith_int(BASE**2).eq(rbigint([0, 0, 1], 1))
     assert rbigint.fromrarith_int(-17).eq(rbigint([17], -1))
     assert rbigint.fromrarith_int(-(BASE - 1)).eq(rbigint([BASE - 1], -1))
     assert rbigint.fromrarith_int(-BASE).eq(rbigint([0, 1], -1))
     assert rbigint.fromrarith_int(-(BASE**2)).eq(rbigint([0, 0, 1], -1))
Exemplo n.º 4
0
 def test_args_from_int(self):
     BASE = 1 << SHIFT
     assert rbigint.fromrarith_int(0).eq(rbigint([0], 0))
     assert rbigint.fromrarith_int(17).eq(rbigint([17], 1))
     assert rbigint.fromrarith_int(BASE-1).eq(rbigint([BASE-1], 1))
     assert rbigint.fromrarith_int(BASE).eq(rbigint([0, 1], 1))
     assert rbigint.fromrarith_int(BASE**2).eq(rbigint([0, 0, 1], 1))
     assert rbigint.fromrarith_int(-17).eq(rbigint([17], -1))
     assert rbigint.fromrarith_int(-(BASE-1)).eq(rbigint([BASE-1], -1))
     assert rbigint.fromrarith_int(-BASE).eq(rbigint([0, 1], -1))
     assert rbigint.fromrarith_int(-(BASE**2)).eq(rbigint([0, 0, 1], -1))
Exemplo n.º 5
0
 def test_args_from_int(self):
     BASE = 1 << SHIFT
     MAX = int(BASE-1)
     assert rbigint.fromrarith_int(0).eq(bigint([0], 0))
     assert rbigint.fromrarith_int(17).eq(bigint([17], 1))
     assert rbigint.fromrarith_int(MAX).eq(bigint([MAX], 1))
     assert rbigint.fromrarith_int(r_longlong(BASE)).eq(bigint([0, 1], 1))
     assert rbigint.fromrarith_int(r_longlong(BASE**2)).eq(
         bigint([0, 0, 1], 1))
     assert rbigint.fromrarith_int(-17).eq(bigint([17], -1))
     assert rbigint.fromrarith_int(-MAX).eq(bigint([MAX], -1))
     assert rbigint.fromrarith_int(-MAX-1).eq(bigint([0, 1], -1))
     assert rbigint.fromrarith_int(r_longlong(-(BASE**2))).eq(
         bigint([0, 0, 1], -1))
Exemplo n.º 6
0
 def unique_id(self, space):
     if self.user_overridden_class:
         return W_Object.unique_id(self, space)
     from pypy.rlib.longlong2float import float2longlong
     from pypy.objspace.std.model import IDTAG_FLOAT as tag
     val = float2longlong(space.float_w(self))
     b = rbigint.fromrarith_int(val)
     b = b.lshift(3).or_(rbigint.fromint(tag))
     return space.newlong_from_rbigint(b)
Exemplo n.º 7
0
 def immutable_unique_id(self, space):
     if self.user_overridden_class:
         return None
     from pypy.rlib.longlong2float import float2longlong
     from pypy.objspace.std.model import IDTAG_FLOAT as tag
     val = float2longlong(space.float_w(self))
     b = rbigint.fromrarith_int(val)
     b = b.lshift(3).or_(rbigint.fromint(tag))
     return space.newlong_from_rbigint(b)
Exemplo n.º 8
0
 def test_args_from_uint(self):
     BASE = 1 << SHIFT
     assert rbigint.fromrarith_int(r_uint(0)).eq(rbigint([0], 0))
     assert rbigint.fromrarith_int(r_uint(17)).eq(rbigint([17], 1))
     assert rbigint.fromrarith_int(r_uint(BASE-1)).eq(rbigint([BASE-1], 1))
     assert rbigint.fromrarith_int(r_uint(BASE)).eq(rbigint([0, 1], 1))
     assert rbigint.fromrarith_int(r_uint(BASE**2)).eq(rbigint([0, 0, 1], 1))
     assert rbigint.fromrarith_int(r_uint(sys.maxint)).eq(
         rbigint.fromint(sys.maxint))
     assert rbigint.fromrarith_int(r_uint(sys.maxint+1)).eq(
         rbigint.fromlong(sys.maxint+1))
     assert rbigint.fromrarith_int(r_uint(2*sys.maxint+1)).eq(
         rbigint.fromlong(2*sys.maxint+1))
Exemplo n.º 9
0
 def test_args_from_uint(self):
     BASE = 1 << SHIFT
     assert rbigint.fromrarith_int(r_uint(0)).eq(rbigint([0], 0))
     assert rbigint.fromrarith_int(r_uint(17)).eq(rbigint([17], 1))
     assert rbigint.fromrarith_int(r_uint(BASE-1)).eq(rbigint([BASE-1], 1))
     assert rbigint.fromrarith_int(r_uint(BASE)).eq(rbigint([0, 1], 1))
     assert rbigint.fromrarith_int(r_uint(BASE**2)).eq(rbigint([0, 0, 1], 1))
     assert rbigint.fromrarith_int(r_uint(sys.maxint)).eq(
         rbigint.fromint(sys.maxint))
     assert rbigint.fromrarith_int(r_uint(sys.maxint+1)).eq(
         rbigint.fromlong(sys.maxint+1))
     assert rbigint.fromrarith_int(r_uint(2*sys.maxint+1)).eq(
         rbigint.fromlong(2*sys.maxint+1))
Exemplo n.º 10
0
 def fromrarith_int(i):
     return W_LongObject(rbigint.fromrarith_int(i))
Exemplo n.º 11
0
 def fromrarith_int(i):
     return W_LongObject(rbigint.fromrarith_int(i))
Exemplo n.º 12
0
 def fn():
     return (rbigint.fromrarith_int(0),
             rbigint.fromrarith_int(17),
             rbigint.fromrarith_int(-17),
             rbigint.fromrarith_int(r_uint(0)),
             rbigint.fromrarith_int(r_uint(17)))
Exemplo n.º 13
0
 def fn(i):
     n = rbigint.fromrarith_int(values[i])
     return n.str()
Exemplo n.º 14
0
 def asbigint(w_self):
     return rbigint.fromrarith_int(w_self.longlong)
Exemplo n.º 15
0
 def asbigint(w_self):
     return rbigint.fromrarith_int(w_self.longlong)
Exemplo n.º 16
0
 def fn(x):
     n1 = rbigint.fromrarith_int(x)
     n2 = rbigint.fromrarith_int(r_uint(x))
     return '%s %s' % (n1.str(), n2.str())
Exemplo n.º 17
0
 def fn(i):
     n = rbigint.fromrarith_int(values[i])
     return n.str()