25.2 Bit Library | LabJack
« Close

Datasheets and User Guides

App Notes

Software & Driver

Saturday/Sunday, March 28th&29th, 2020
Support: LabJack engineers available through email and chat.
Shipping: We are processing and shipping all orders.
Stock: 55/56 products in stock. More details.
Supply Chain: Some disruptions. More details.

25.2 Bit Library


Lua in T-Series devices is based on Lua 5.1.4 which did not include a bitwise library. A subset of Lua 5.2's Bitwise Library have been added. The name of the library is bin or bit instead of bit32. To use the AND function use bin.band instead of bit32.band

Limitations on T-Series

The T4 and T7 use 32-bit floating point (single precision) numbers. To perform bitwise operations the 32-bit float is converted into an integer. The bitwise operation is performed. Then the integer is converted back into a floating point number. When converting to an integer some information can be lost. Any decimal places will be truncated off and only up to 23-bits will make it to the integer. This is because 8 bits is used for the exponent and 1 bit for sign.


Operation of the below functions match the Lua 5.2 bitwise library with the exception of the data type limitations. 

  • arshift
  • band
  • bnot
  • bor
  • bxor
  • lshift
  • rshift