Library bits

Bit manipulation library.

Author:

  • Patrick Donnelly <batrick@batbytes.com>

Copyright © Same as Nmap -- see https://nmap.org/book/man-legal.html

Source: https://svn.nmap.org/nmap/nselib/bits.lua

Functions

arshift (a, b)

Returns a arithmetically right-shifted by b places.

reverse (n, size)

Reverses bits in integer.

Functions

arshift (a, b)

Returns a arithmetically right-shifted by b places.

Parameters

a
Number to perform the shift on.
b
Number of shifts.
reverse (n, size)

Reverses bits in integer.

Parameters

n
The integer.
size
The bit width of the integer (default: 8).

Return value:

The reversed integer.