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

Python rarithmetic.r_longlong函数代码示例

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

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



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

示例1: g

 def g(n, m, o):
     # This function should be completely marked as residual by
     # codewriter.py on 32-bit platforms.  On 64-bit platforms,
     # this function should be JITted and the test should pass too.
     n = r_longlong(n)
     m = r_longlong(m)
     return intmask((n*m) // o)
开发者ID:enyst,项目名称:plexnet,代码行数:7,代码来源:test_basic.py


示例2: 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


示例3: f

 def f(n1, n2):
     # n == -30000000000000
     n = (r_longlong(n1) << 32) | r_longlong(n2)
     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 = n + 2000000000
     compare(o, -6985, -1948404736)
     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 = -o
     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,代码行数:33,代码来源:test_longlong.py


示例4: 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


示例5: test_slonglong_args

 def test_slonglong_args(self):
     """
         long long sum_xy_longlong(long long x, long long y)
         {
             return x+y;
         }
     """
     maxint32 = 2147483647 # we cannot really go above maxint on 64 bits
                           # (and we would not test anything, as there long
                           # is the same as long long)
     libfoo = self.get_libfoo()
     func = (libfoo, 'sum_xy_longlong', [types.slonglong, types.slonglong],
             types.slonglong)
     if IS_32_BIT:
         x = r_longlong(maxint32+1)
         y = r_longlong(maxint32+2)
         zero = longlong2float(r_longlong(0))
     else:
         x = maxint32+1
         y = maxint32+2
         zero = 0
     res = self.call(func, [x, y], rffi.LONGLONG, init_result=zero)
     if IS_32_BIT:
         # obscure, on 32bit it's really a long long, so it returns a
         # DOUBLE because of the JIT hack
         res = float2longlong(res)
     expected = maxint32*2 + 3
     assert res == expected
开发者ID:ieure,项目名称:pypy,代码行数:28,代码来源:test_libffi.py


示例6: _impl_pow

def _impl_pow(space, iv, w_int2, iz=r_longlong(0)):
    iw = w_int2.intval
    if iw < 0:
        if iz != 0:
            raise OperationError(space.w_TypeError,
                             space.wrap("pow() 2nd argument "
                 "cannot be negative when 3rd argument specified"))
        ## bounce it, since it always returns float
        raise FailedToImplementArgs(space.w_ValueError,
                                space.wrap("integer exponentiation"))
    temp = iv
    ix = r_longlong(1)
    try:
        while iw > 0:
            if iw & 1:
                ix = llong_mul_ovf(ix, temp)
            iw >>= 1   #/* Shift exponent down by 1 bit */
            if iw==0:
                break
            temp = llong_mul_ovf(temp, temp) #/* Square the value of temp */
            if iz:
                #/* If we did a multiplication, perform a modulo */
                ix = ix % iz
                temp = temp % iz
        if iz:
            ix = ix % iz
    except OverflowError:
        raise FailedToImplementArgs(space.w_OverflowError,
                                space.wrap("integer exponentiation"))
    return W_SmallLongObject(ix)
开发者ID:ParitoshThapliyal59,项目名称:pypy,代码行数:30,代码来源:smalllongobject.py


示例7: f

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


示例8: g

 def g(n, m, o, p):
     # On 64-bit platforms, long longs == longs.  On 32-bit platforms,
     # this function should be either completely marked as residual
     # (with supports_longlong==False), or be compiled as a
     # sequence of residual calls (with long long arguments).
     n = r_longlong(n)
     m = r_longlong(m)
     return intmask((n*m + p) // o)
开发者ID:gorakhargosh,项目名称:pypy,代码行数:8,代码来源:test_longlong.py


示例9: test_float_conversion_implicit

 def test_float_conversion_implicit(self):
     def f(ii):
         return 1.0 + ii
     res = self.interpret(f, [r_longlong(100000000)])
     assert type(res) is float
     assert res == 100000001.
     res = self.interpret(f, [r_longlong(1234567890123456789)])
     assert type(res) is float
     assert self.float_eq(res, 1.2345678901234568e+18)
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:9,代码来源:test_rint.py


示例10: pack_float

def pack_float(result, number, size, bigendian):
    """Append to 'result' the 'size' characters of the 32-bit or 64-bit
    IEEE representation of the number.
    """
    if size == 4:
        bias = 127
        exp = 8
        prec = 23
    else:
        bias = 1023
        exp = 11
        prec = 52

    if isnan(number):
        sign = 0x80
        man, e = 1.5, bias + 1
    else:
        if number < 0:
            sign = 0x80
            number *= -1
        elif number == 0.0:
            for i in range(size):
                result.append('\x00')
            return
        else:
            sign = 0x00
        if isinf(number):
            man, e = 1.0, bias + 1
        else:
            man, e = math.frexp(number)

    if 0.5 <= man and man < 1.0:
        man *= 2
        e -= 1
    man -= 1
    e += bias
    power_of_two = r_longlong(1) << prec
    mantissa = r_longlong(power_of_two * man + 0.5)
    if mantissa >> prec :
        mantissa = 0
        e += 1

    for i in range(size-2):
        result.append(chr(mantissa & 0xff))
        mantissa >>= 8
    x = (mantissa & ((1<<(15-exp))-1)) | ((e & ((1<<(exp-7))-1))<<(15-exp))
    result.append(chr(x))
    x = sign | e >> (exp - 7)
    result.append(chr(x))
    if bigendian:
        first = len(result) - size
        last = len(result) - 1
        for i in range(size // 2):
            (result[first + i], result[last - i]) = (
                result[last - i], result[first + i])
开发者ID:alkorzt,项目名称:pypy,代码行数:55,代码来源:ieee.py


示例11: test_args_from_int

 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))
开发者ID:gorakhargosh,项目名称:pypy,代码行数:14,代码来源:test_rbigint.py


示例12: dump_int

def dump_int(buf, x):
    # only use TYPE_INT on 32-bit platforms
    if LONG_BIT > 32:
        dump_longlong(buf, r_longlong(x))
    else:
        buf.append(TYPE_INT)
        w_long(buf, x)
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:7,代码来源:rmarshal.py


示例13: 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


示例14: test_contains_unsupported_variable_type

def test_contains_unsupported_variable_type():
    def f(x):
        return x
    graph = support.getgraph(f, [5])
    for sf in [False, True]:
        for sll in [False, True]:
            for ssf in [False, True]:
                assert not contains_unsupported_variable_type(graph, sf,
                                                              sll, ssf)
    #
    graph = support.getgraph(f, [5.5])
    for sf in [False, True]:
        for sll in [False, True]:
            for ssf in [False, True]:
                res = contains_unsupported_variable_type(graph, sf, sll, ssf)
                assert res is not sf
    #
    graph = support.getgraph(f, [r_singlefloat(5.5)])
    for sf in [False, True]:
        for sll in [False, True]:
            for ssf in [False, True]:
                res = contains_unsupported_variable_type(graph, sf, sll, ssf)
                assert res == (not ssf)
    #
    graph = support.getgraph(f, [r_longlong(5)])
    for sf in [False, True]:
        for sll in [False, True]:
            for ssf in [False, True]:
                res = contains_unsupported_variable_type(graph, sf, sll, ssf)
                assert res == (sys.maxint == 2147483647 and not sll)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:30,代码来源:test_policy.py


示例15: 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


示例16: op_cast_float_to_longlong

def op_cast_float_to_longlong(f):
    assert type(f) is float
    r = float(0x100000000)
    small = f / r
    high = int(small)
    truncated = int((small - high) * r)
    return r_longlong(high) * 0x100000000 + truncated
开发者ID:alkorzt,项目名称:pypy,代码行数:7,代码来源:opimpl.py


示例17: test_neg_abs_ovf

    def test_neg_abs_ovf(self):
        for op in (operator.neg, abs):
            def f(x):
                try:
                    return ovfcheck(op(x))
                except OverflowError:
                    return 0
            res = self.interpret(f, [-1])
            assert res == 1
            res = self.interpret(f, [int(-1<<(r_int.BITS-1))])
            assert res == 0

            res = self.interpret(f, [r_longlong(-1)])
            assert res == 1
            res = self.interpret(f, [r_longlong(-1)<<(r_longlong.BITS-1)])
            assert res == 0
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:16,代码来源:test_rint.py


示例18: pow_ovr

def pow_ovr(space, w_int1, w_int2):
    try:
        return _impl_pow(space, r_longlong(w_int1.intval), w_int2)
    except FailedToImplementArgs:
        from pypy.objspace.std import longobject
        w_a = W_LongObject.fromint(space, w_int1.intval)
        w_b = W_LongObject.fromint(space, w_int2.intval)
        return longobject.pow__Long_Long_None(space, w_a, w_b, space.w_None)
开发者ID:ParitoshThapliyal59,项目名称:pypy,代码行数:8,代码来源:smalllongobject.py


示例19: test_direct

def test_direct():
    space = gettestobjspace(**{"objspace.std.withsmalllong": True})
    w5 = space.wrap(r_longlong(5))
    assert isinstance(w5, W_SmallLongObject)
    wlarge = space.wrap(r_longlong(0x123456789ABCDEFL))
    #
    assert space.int_w(w5) == 5
    if sys.maxint < 0x123456789ABCDEFL:
        py.test.raises(OperationError, space.int_w, wlarge)
    else:
        assert space.int_w(wlarge) == 0x123456789ABCDEF
    #
    assert space.pos(w5) is w5
    assert space.abs(w5) is w5
    wm5 = space.wrap(r_longlong(-5))
    assert space.int_w(space.abs(wm5)) == 5
    assert space.int_w(space.neg(w5)) == -5
    assert space.is_true(w5) is True
    assert space.is_true(wm5) is True
    w0 = space.wrap(r_longlong(0))
    assert space.is_true(w0) is False
    #
    w14000000000000 = space.wrap(r_longlong(0x14000000000000L))
    assert space.is_true(space.eq(
        space.lshift(w5, space.wrap(49)), w14000000000000)) is False
    assert space.is_true(space.eq(
        space.lshift(w5, space.wrap(50)), w14000000000000)) is True
    #
    w_huge = space.sub(space.lshift(w5, space.wrap(150)), space.wrap(1))
    wx = space.and_(w14000000000000, w_huge)
    assert space.is_true(space.eq(wx, w14000000000000))
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:31,代码来源:test_smalllongobject.py


示例20: test_signed_longlong

 def test_signed_longlong(self):
     space = self.space
     maxint32 = 2147483647 # we cannot really go above maxint on 64 bits
                           # (and we would not test anything, as there long
                           # is the same as long long)
     expected = maxint32+1
     if IS_32_BIT:
         expected = r_longlong(expected)
     self.check(app_types.slonglong, space.wrap(maxint32+1), expected)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:9,代码来源:test_type_converter.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python rarithmetic.r_singlefloat函数代码示例发布时间:2022-05-27
下一篇:
Python rarithmetic.ovfcheck函数代码示例发布时间: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