Skip to main content

Bitwise

Functions

arrayToBitFlags

arrayToBitFlags<T>(array): BitFlags<T>

Helper function to convert a set of flags to a single BitFlags object.

Type parameters

NameType
Textends BitFlag | BitFlag128

Parameters

NameType
arrayreadonly T[]

Returns

BitFlags<T>

Defined in

packages/isaacscript-common/src/functions/bitwise.ts:6


convertBinaryToDecimal

convertBinaryToDecimal(bits): number

Helper function to convert an array of bits to the resulting decimal number.

Parameters

NameType
bitsreadonly int[]

Returns

number

Defined in

packages/isaacscript-common/src/functions/bitwise.ts:18


convertDecimalToBinary

convertDecimalToBinary(num, minLength?): readonly int[]

Helper function to convert a number to an array of bits.

Parameters

NameTypeDescription
numnumberThe number to convert.
minLength?intOptional. Equal to the minimum amount of bits that should be returned. If the converted number of bits is below this number, 0's will be padded to the left side until the minimum length is met. Default is undefined (which will not cause any padding).

Returns

readonly int[]

Defined in

packages/isaacscript-common/src/functions/bitwise.ts:32


countSetBits

countSetBits(num): int

Helper function to count the number of bits that are set to 1 in a binary representation of a number.

Parameters

NameType
numint

Returns

int

Defined in

packages/isaacscript-common/src/functions/bitwise.ts:62


getKBitOfN

getKBitOfN(k, n): int

Helper function to get the value of a specific but in a binary representation of a number.

Parameters

NameType
kint
nint

Returns

int

Defined in

packages/isaacscript-common/src/functions/bitwise.ts:74


getNumBitsOfN

getNumBitsOfN(n): int

Helper function to get the number of bits in a binary representation of a number.

Parameters

NameType
nint

Returns

int

Defined in

packages/isaacscript-common/src/functions/bitwise.ts:79


setToBitFlags

setToBitFlags<T>(set): BitFlags<T>

Helper function to convert a set of flags to a single BitFlags object.

Type parameters

NameType
Textends BitFlag | BitFlag128

Parameters

NameType
setReadonlySet<T>

Returns

BitFlags<T>

Defined in

packages/isaacscript-common/src/functions/bitwise.ts:90