« Close

Datasheets and User Guides

App Notes

Software & Driver

 

25.2 Bit Library

Overview

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.

Functions

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