Home page logo
/
Intro Reference Guide Book Install Guide
Download Changelog Zenmap GUI Docs
Bug Reports OS Detection Propaganda Related Projects
In the Movies In the News

Sponsors


Library bit

Bitwise operations on integers.

Lua does not provide bitwise logical operations. Since they are often useful for low-level network communication, Reuben Thomas' BitLib (http://luaforge.net/projects/bitlib) for Lua has been integrated into NSE. The arguments to the bitwise operation functions should be integers. The number of bits available for logical operations depends on the data type used to represent Lua numbers. This is typically 8-byte IEEE floats (double), which give 53 bits (the size of the mantissa).

This implies that the bitwise operations won't work (as expected) for numbers larger than 10^14. You can use them with 32-bit wide numbers without any problems. Operations involving 64-bit wide numbers, however, may not return the expected result.

The logical operations start with "b" to avoid clashing with reserved words; although xor isn't a reserved word, it seemed better to use bxor for consistency.

Author:
Reuben Thomas

Copyright© BSD License

Functions

arshift (a, b)

Returns a arithmetically right-shifted by b places.

band (...)

Returns the bitwise and of all its arguments.

bnot (a)

Returns the one's complement of a.

bor (...)

Returns the bitwise or of all its arguments.

bxor (...)

Returns the bitwise exclusive or of all its arguments.

lshift (a, b)

Returns a left-shifted by b places.

mod (a, b)

Returns the integer remainder of a divided by b.

rshift (a, b)

Returns a right-shifted by b places.



Functions

arshift (a, b)

Returns a arithmetically right-shifted by b places.

Parameters

  • a: Number to perform the shift on.
  • b: Number of shifts.
band (...)

Returns the bitwise and of all its arguments.

Parameters

  • ...: A variable number of Numbers to and.

Return value:

The anded result.
bnot (a)

Returns the one's complement of a.

Parameters

  • a: Number.

Return value:

The one's complement of a.
bor (...)

Returns the bitwise or of all its arguments.

Parameters

  • ...: A variable number of Numbers to or.

Return value:

The ored result.
bxor (...)

Returns the bitwise exclusive or of all its arguments.

Parameters

  • ...: A variable number of Numbers to exclusive or.

Return value:

The exclusive ored result.
lshift (a, b)

Returns a left-shifted by b places.

Parameters

  • a: Number to perform the shift on.
  • b: Number of shifts.
mod (a, b)

Returns the integer remainder of a divided by b.

Parameters

  • a: Dividend.
  • b: Divisor.
rshift (a, b)

Returns a right-shifted by b places.

Parameters

  • a: Number to perform the shift on.
  • b: Number of shifts.

Nmap Site Navigation

Intro Reference Guide Book Install Guide
Download Changelog Zenmap GUI Docs
Bug Reports OS Detection Propaganda Related Projects
In the Movies In the News
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]
AlienVault