Log In  


Cart #knutil_bpack-2 | 2024-12-21 | Code ▽ | Embed ▽ | No License

Feature Overview

BPACK() pack the value of the bit specification with bit width.

  • If multiple bit values are specified, pack toward the most significant bit.
  • To start bit packing from the decimal point bit, set [number s] to a negative value.
  • If there are fewer bit width elements for the value to pack, the bit width elements are rotated.
  • This function consumes 38 Token.
v=bpack({8,4},0,0xff,0xb)
?tostr(v,1) -- 0x0bff.0000 (bit-left-shift:0)

v=bpack({8,4},4,0xff,0xb)
?tostr(v,1) -- 0x0bff.0000 (bit-left-shift:4)

This function is included in the KNUTIL library.

release note


v0.2a

  • changed the bit shift direction at the start of packing (negative is toward the decimal point).

v0.2

  • change the bit order to little endian.

v0.1

  • first release



[Please log in to post a comment]