User Tools

Site Tools


lgscript:bit_library

Bit32 Library

Functions that manipulate numbers as 32-bit integers. Input numbers can be as low as -231 and as high as 232-1. (Some of those numbers will have the same binary representation.) The processing is done using unsigned 32-bit numbers, so the return values are always greater than or equal to 0.

arshift

Arithmetic right shift.

Returns number The shifted value.
Parameter number A bitfield value.
Parameter number Number of places to shift.

Shift the bits in the number to the right. The bits shifted in from the left will be the same as the previous high-order bit. A negative shift will go to the left and set the low-order bits to 0.

band

Bitwise and of the given numbers.

Returns number The and’ed value.
Parameter number ... Values to and together.

bnot

Bitwise not of the number.

Returns number The inverted value.
Parameter number Value to invert.

bor

Bitwise or of the given numbers.

Returns number The or’ed value.
Parameter number ... Values to or together.

btest

Do bitwise and and test the result.

Returns boolean True if the result is not zero.
Parameter number ... Values to and together.

bxor

Bitwise xor of the given numbers.

Returns number The xored value.
Parameter number ... Values to xor together.

lrotate

Left rotate.

Returns number The shifted value.
Parameter number A bitfield value.
Parameter number Number of places to shift.

Shift the bits in the number to the left. A negative shift will go to the right. Each bit removed from the left side will be inserted on the right side. So the number will restore itself if shifted 32 places.

lshift

Left shift.

Returns number The shifted value.
Parameter number A bitfield value.
Parameter number Number of places to shift.

Shift the bits in the number to the left. A negative shift will go to the right. The shifted in bits are set to 0.

rrotate

Right rotate.

Returns number The shifted value.
Parameter number A bitfield value.
Parameter number Number of places to shift.

Shift the bits in the number to the right. A negative shift will go to the left. Each bit removed from the right side will be inserted on the left side. So the number will restore itself if shifted 32 places.

rshift

Right shift.

Returns number The shifted value.
Parameter number A bitfield value.
Parameter number Number of places to shift.

Shift the bits in the number to the right. A negative shift will go to the left. The shifted in bits are set to 0.

lgscript/bit_library.txt · Last modified: 2011/05/21 01:54 by telliamed