LUA5.2版本中提供的位运算




Bitwise Operations
This library provides bitwise operations. It provides all its functions inside the table bit32.
all functions accept numeric arguments in the range (-2^51,+2^51);
each argument is normalized to the remainder of its division by 2^32 and truncated to an integer (in some unspecified way),
so that its final value falls in the range [0,2^32 - 1].
all results are in the range [0,2^32 - 1]. Note that bit32.bnot(0) is 0xFFFFFFFF, which is different from -1

在bit32 table中提供位操作运算。所有位操作运算可以接受数值的范围为(-2^51,+2^51);
但是每一个参数都通过除以2^32取得余数来做统一化。把参数转换成一个整型。最终,每一个参数的范围为[0,2^32 - 1].
同样,所有结果的范围为[0,2^32 - 1].



bit32.rshift (x, disp)
Returns the number x shifted disp bits to the right.
The number disp may be any representable integer. Negative displacements shift to the left.
In any direction, vacant bits are fille

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值