• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python rarithmetic.r_ulonglong函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: _AsULonglong_ignore_sign

def _AsULonglong_ignore_sign(v):
    x = r_ulonglong(0)
    i = v._numdigits() - 1
    while i >= 0:
        prev = x
        x = (x << SHIFT) + v._digit(i)
        if (x >> SHIFT) != prev:
                raise OverflowError(
                    "long int too large to convert to unsigned long long int")
        i -= 1
    return x
开发者ID:alkorzt,项目名称:pypy,代码行数:11,代码来源:rbigint.py


示例17: test_struct_fields_longlong

 def test_struct_fields_longlong(self):
     POINT = lltype.Struct('POINT',
                           ('x', rffi.LONGLONG),
                           ('y', rffi.ULONGLONG)
                           )
     y_ofs = 8
     p = lltype.malloc(POINT, flavor='raw')
     p.x = r_longlong(123)
     p.y = r_ulonglong(456)
     addr = rffi.cast(rffi.VOIDP, p)
     assert struct_getfield_longlong(types.slonglong, addr, 0) == 123
     assert struct_getfield_longlong(types.ulonglong, addr, y_ofs) == 456
     #
     v = rffi.cast(lltype.SignedLongLong, r_ulonglong(9223372036854775808))
     struct_setfield_longlong(types.slonglong, addr, 0, v)
     struct_setfield_longlong(types.ulonglong, addr, y_ofs, r_longlong(-1))
     assert p.x == -9223372036854775808
     assert rffi.cast(lltype.UnsignedLongLong, p.y) == 18446744073709551615
     #
     lltype.free(p, flavor='raw')
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:20,代码来源:test_libffi.py


示例18: _init

    def _init(self):
        """Set this object to an initial empty state.
        """
        self.count = r_ulonglong(0)   # total number of bytes
        self.input = ""   # pending unprocessed data, < 64 bytes

        # Load magic initialization constants.
        self.A = r_uint(0x67452301L)
        self.B = r_uint(0xefcdab89L)
        self.C = r_uint(0x98badcfeL)
        self.D = r_uint(0x10325476L)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:11,代码来源:rmd5.py


示例19: _init

    def _init(self):
        "Initialisation."
        self.count = r_ulonglong(0)   # total number of bytes
        self.input = ""   # pending unprocessed data, < 64 bytes

        # Initial 160 bit message digest (5 times 32 bit).
        self.H0 = r_uint(0x67452301L)
        self.H1 = r_uint(0xEFCDAB89L)
        self.H2 = r_uint(0x98BADCFEL)
        self.H3 = r_uint(0x10325476L)
        self.H4 = r_uint(0xC3D2E1F0L)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:11,代码来源:rsha.py


示例20: test_compare_big_ullongs

 def test_compare_big_ullongs(self):
     bigval = r_ulonglong(9223372036854775808L)
     def fn(x):
         if x > bigval: return 1
         if x == bigval: return 0
         if x < bigval: return -1
         return -2
     
     for val in (bigval-1, bigval, bigval+1):
         expected = fn(val)
         res = self.interpret(fn, [val])
         assert res == expected
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:12,代码来源:operations.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python rbigint.fromint函数代码示例发布时间:2022-05-27
下一篇:
Python rarithmetic.r_uint函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap