Lua Bit Operations Module

LuaBitOp是一个为Lua5.1/5.2设计的C扩展模块,提供了针对数字的位运算操作。它支持多种位运算函数,如按位与、按位或等,并且在16位、32位和64位平台上具有一致的语义。该模块适用于不同的lua_Number类型,并在多种操作系统上运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://bitop.luajit.org/index.html

Lua BitOp is a C extension module for Lua 5.1/5.2which adds bitwise operations on numbers.

Lua BitOp is Copyright © 2008-2012 Mike Pall.Lua BitOp is free software, released under theMIT license(same license as the Lua core).

Features

  • Supported functions:bit.tobit, bit.tohex, bit.bnot, bit.band, bit.bor, bit.bxor,bit.lshift, bit.rshift, bit.arshift, bit.rol, bit.ror, bit.bswap
  • Consistent semanticsacross 16, 32 and 64 bit platforms.
  • Supports different lua_Number types:either IEEE 754 doubles, int32_t or int64_t.
  • Runs on Linux, *BSD, Mac OS X, Windows and probably anything elseyou can find.
  • Simple installation on all systems.No bulky configure scripts. Embedded-systems-friendly.
  • Internal self-test on startup to detect miscompiles.Includes a comprehensive test and benchmark suite.
  • Compatible with the built-in bitwise operations inLuaJIT 2.0.
  • It's as fast as you can get with the standard Lua/C API.

More ...

Please click on one of the links in the navigation bar to your leftto learn more.

Please visit the Download page to fetchthe current version of Lua BitOp.

News

2012-05-08 Lua BitOp 1.0.2 has been released

This release adds compatibility with both Lua 5.1 and Lua 5.2.

Embedding Lua BitOp

If you're embedding Lua into your application, it's quite simple toadd Lua BitOp as a static module:

1. Copy the file bit.c from the Lua BitOp distributionto your Lua source code directory.

2. Add this file to your build script (e.g. modify the Makefile) orimport it as a build dependency in your IDE.

3. Edit lualib.h and add the following two lines:

#define LUA_BITLIBNAME "bit"
LUALIB_API int luaopen_bit(lua_State *L);

4. Edit linit.c and add this immediately before the linewith {NULL, NULL}:

  {LUA_BITLIBNAME, luaopen_bit},

5. Now recompile and you're done!





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值