当前位置: 首页>>代码示例>>Python>>正文


Python rarithmetic.r_ulonglong函数代码示例

本文整理汇总了Python中pypy.rlib.rarithmetic.r_ulonglong函数的典型用法代码示例。如果您正苦于以下问题:Python r_ulonglong函数的具体用法?Python r_ulonglong怎么用?Python r_ulonglong使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了r_ulonglong函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: malloc_slowpath

 def malloc_slowpath(size):
     from pypy.rlib.rarithmetic import r_ulonglong
     assert size == 8
     nadr = rffi.cast(lltype.Signed, self.nursery)
     self.addrs[0] = 99999    # should be overridden by the caller
     return ((r_ulonglong(nadr + size) << 32) |     # this part in edx
              r_ulonglong(nadr))                    # this part in eax
开发者ID:enyst,项目名称:plexnet,代码行数:7,代码来源:test_gc_integration.py

示例2: f

 def f(n1, n2):
     # n == 30002000000000
     n = (r_ulonglong(n1) << 32) | r_ulonglong(n2)
     compare(n, 6985, 1653437440)
     compare(n < n,  0, 0)
     compare(n <= n, 0, 1)
     compare(n == n, 0, 1)
     compare(n != n, 0, 0)
     compare(n >  n, 0, 0)
     compare(n >= n, 0, 1)
     o = (r_ulonglong(n1) << 32) | r_ulonglong(r_uint(n2) + 1000000000)
     compare(o, 6985, -1641529856)
     compare(n <  o, 0, 1)     # low word differs
     compare(n <= o, 0, 1)
     compare(o <  n, 0, 0)
     compare(o <= n, 0, 0)
     compare(n >  o, 0, 0)
     compare(n >= o, 0, 0)
     compare(o >  n, 0, 1)
     compare(o >= n, 0, 1)
     compare(n == o, 0, 0)
     compare(n != o, 0, 1)
     p = ~n
     compare(n <  p, 0, 1)     # high word differs
     compare(n <= p, 0, 1)
     compare(p <  n, 0, 0)
     compare(p <= n, 0, 0)
     compare(n >  p, 0, 0)
     compare(n >= p, 0, 0)
     compare(p >  n, 0, 1)
     compare(p >= n, 0, 1)
     compare(n == p, 0, 0)
     compare(n != p, 0, 1)
     return 1
开发者ID:gorakhargosh,项目名称:pypy,代码行数:34,代码来源:test_longlong.py

示例3: min_max_acc_method

def min_max_acc_method(size, signed):
    if signed:
        min = -(2 ** (8*size-1))
        max = (2 ** (8*size-1)) - 1
        if size <= native_int_size:
            accept_method = 'accept_int_arg'
            min = int(min)
            max = int(max)
        else:
            accept_method = 'accept_longlong_arg'
            min = r_longlong(min)
            max = r_longlong(max)
    else:
        min = 0
        max = (2 ** (8*size)) - 1
        if size < native_int_size:
            accept_method = 'accept_int_arg'
        elif size == native_int_size:
            accept_method = 'accept_uint_arg'
            min = r_uint(min)
            max = r_uint(max)
        else:
            accept_method = 'accept_ulonglong_arg'
            min = r_ulonglong(min)
            max = r_ulonglong(max)
    return min, max, accept_method
开发者ID:antoine1fr,项目名称:pygirl,代码行数:26,代码来源:standardfmttable.py

示例4: test_ullongoperations

def test_ullongoperations():
    tests = adapt_tests(general_tests, r_ulonglong, UnsignedLongLong, "ullong") + [
        # binary wraparounds
        ("ullong_add", UnsignedLongLong,
                r_ulonglong(r_ulonglong.MASK), r_ulonglong(10)),
    ]
    for t in tests:
        yield optest, t
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:8,代码来源:test_llops.py

示例5: f

 def f(x):
     if x == r_ulonglong(3):
         return 9
     elif x == r_ulonglong(9):
         return 27
     elif x == r_ulonglong(27):
         return 3
     return 0
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:8,代码来源:test_backendoptimized.py

示例6: test_ulonglongmask

 def test_ulonglongmask(self):
     assert rbigint.fromlong(-1).ulonglongmask() == r_ulonglong(-1)
     assert rbigint.fromlong(0).ulonglongmask() == r_ulonglong(0)
     assert (rbigint.fromlong(sys.maxint).ulonglongmask() ==
             r_ulonglong(sys.maxint))
     assert (rbigint.fromlong(9**50).ulonglongmask() ==
             r_ulonglong(9**50))
     assert (rbigint.fromlong(-9**50).ulonglongmask() ==
             r_ulonglong(-9**50))
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:9,代码来源:test_rbigint.py

示例7: malloc_fixedsize_slowpath

 def malloc_fixedsize_slowpath(size):
     try:
         gcref = llop1.do_malloc_fixedsize_clear(llmemory.GCREF,
                                     0, size, True, False, False)
     except MemoryError:
         fatalerror("out of memory (from JITted code)")
         return r_ulonglong(0)
     res = rffi.cast(lltype.Signed, gcref)
     nurs_free = llop1.gc_adr_of_nursery_free(llmemory.Address).signed[0]
     return r_ulonglong(nurs_free) << 32 | r_ulonglong(r_uint(res))
开发者ID:alkorzt,项目名称:pypy,代码行数:10,代码来源:gc.py

示例8: test_truth_value

 def test_truth_value(self):
     bigzero = r_ulonglong(0)
     big = r_ulonglong(2L**42)
     def func(n, z):
         assert c_int(n)
         assert not c_int(z)
         assert c_int(-1)
         assert not c_byte(z)
         assert not c_char(chr(z))
         # assert not c_float(z)
         assert not c_double(z)
         assert not c_ulonglong(bigzero)
         assert c_ulonglong(big)
     interpret(func, [17, 0])
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:14,代码来源:test_rprimitive.py

示例9: test_wraplonglongs

def test_wraplonglongs():
    space = CPyObjSpace()
    w = space.wrap
    w_res = space.add(w(r_longlong(1)), w(r_ulonglong(1)))
    assert space.eq_w(w_res, w(2))
    res = space.int_w(w_res)
    assert res == 2
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:7,代码来源:test_objspace.py

示例10: test_cast_float_to_ulonglong

def test_cast_float_to_ulonglong():
    f = 12350000000000000000.0
    py.test.raises(OverflowError, r_longlong, f)
    r_longlong(f / 2)   # does not raise OverflowError
    #
    x = llop.cast_float_to_ulonglong(lltype.UnsignedLongLong, f)
    assert x == r_ulonglong(f)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:7,代码来源:test_lloperation.py

示例11: test_wrap

def test_wrap():
    def _is(box1, box2):
        return box1.__class__ == box2.__class__ and box1.value == box2.value

    p = lltype.malloc(lltype.GcStruct("S"))
    po = lltype.cast_opaque_ptr(llmemory.GCREF, p)
    assert _is(wrap(None, 42), BoxInt(42))
    assert _is(wrap(None, 42.5), boxfloat(42.5))
    assert _is(wrap(None, p), BoxPtr(po))
    assert _is(wrap(None, 42, in_const_box=True), ConstInt(42))
    assert _is(wrap(None, 42.5, in_const_box=True), constfloat(42.5))
    assert _is(wrap(None, p, in_const_box=True), ConstPtr(po))
    if longlong.supports_longlong:
        import sys
        from pypy.rlib.rarithmetic import r_longlong, r_ulonglong

        value = r_longlong(-sys.maxint * 17)
        assert _is(wrap(None, value), BoxFloat(value))
        assert _is(wrap(None, value, in_const_box=True), ConstFloat(value))
        value_unsigned = r_ulonglong(-sys.maxint * 17)
        assert _is(wrap(None, value_unsigned), BoxFloat(value))
    sfval = r_singlefloat(42.5)
    ival = longlong.singlefloat2int(sfval)
    assert _is(wrap(None, sfval), BoxInt(ival))
    assert _is(wrap(None, sfval, in_const_box=True), ConstInt(ival))
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:25,代码来源:test_warmstate.py

示例12: test_longlongmask

    def test_longlongmask(self):
        def f(x=r_ulonglong):
            try:
                return longlongmask(x)
            except ValueError:
                return 0

        res = self.interpret(f, [r_ulonglong(5)])
        assert type(res) is r_int64 and res == 5
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:9,代码来源:test_rbuiltin.py

示例13: test_cast

 def test_cast(self):
     def llfn(v):
         return rffi.cast(rffi.VOIDP, v)
     res = self.interpret(llfn, [r_ulonglong(0)])
     assert res == lltype.nullptr(rffi.VOIDP.TO)
     def llfn(v):
         return rffi.cast(rffi.LONGLONG, v)
     res = self.interpret(llfn, [lltype.nullptr(rffi.VOIDP.TO)])
     assert res == 0
     assert isinstance(res, r_longlong)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:10,代码来源:test_rbuiltin.py

示例14: _AsULonglong_mask

def _AsULonglong_mask(v):
    x = r_ulonglong(0)
    i = len(v.digits) - 1
    while i >= 0:
        prev = x
        x = (x << SHIFT) + v.digits[i]
        i -= 1
    if v.sign < 0:
        x = -x
    return x
开发者ID:antoine1fr,项目名称:pygirl,代码行数:10,代码来源:rbigint.py

示例15: test_ulonglong_args

 def test_ulonglong_args(self):
     """
         unsigned long long sum_xy_ulonglong(unsigned long long x,
                                             unsigned long long y)
         {
             return x+y;
         }
     """
     maxint64 = 9223372036854775807 # maxint64+1 does not fit into a
                                    # longlong, but it does into a
                                    # ulonglong
     libfoo = self.get_libfoo()
     func = (libfoo, 'sum_xy_ulonglong', [types.ulonglong, types.ulonglong],
             types.ulonglong)
     x = r_ulonglong(maxint64+1)
     y = r_ulonglong(2)
     res = self.call(func, [x, y], rffi.ULONGLONG, jitif=["longlong"])
     expected = maxint64 + 3
     assert res == expected
开发者ID:gorakhargosh,项目名称:pypy,代码行数:19,代码来源:test_libffi.py


注:本文中的pypy.rlib.rarithmetic.r_ulonglong函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。