Bitwise
Functions
Section titled “Functions”arrayToBitFlags()
Section titled “arrayToBitFlags()”arrayToBitFlags<
T>(array):BitFlags<T>
Defined in: packages/isaacscript-common/src/functions/bitwise.ts:6
Helper function to convert a set of flags to a single BitFlags object.
Type Parameters
Section titled “Type Parameters”T extends BitFlag | BitFlag128
Parameters
Section titled “Parameters”readonly T[]
Returns
Section titled “Returns”BitFlags<T>
convertBinaryToDecimal()
Section titled “convertBinaryToDecimal()”convertBinaryToDecimal(
bits):number
Defined in: packages/isaacscript-common/src/functions/bitwise.ts:18
Helper function to convert an array of bits to the resulting decimal number.
Parameters
Section titled “Parameters”readonly int[]
Returns
Section titled “Returns”number
convertDecimalToBinary()
Section titled “convertDecimalToBinary()”convertDecimalToBinary(
num,minLength?): readonlyint[]
Defined in: packages/isaacscript-common/src/functions/bitwise.ts:32
Helper function to convert a number to an array of bits.
Parameters
Section titled “Parameters”number
The number to convert.
minLength?
Section titled “minLength?”int
Optional. 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
Section titled “Returns”readonly int[]
countSetBits()
Section titled “countSetBits()”countSetBits(
num):int
Defined in: packages/isaacscript-common/src/functions/bitwise.ts:63
Helper function to count the number of bits that are set to 1 in a binary representation of a number.
Parameters
Section titled “Parameters”int
Returns
Section titled “Returns”int
getKBitOfN()
Section titled “getKBitOfN()”getKBitOfN(
k,n):int
Defined in: packages/isaacscript-common/src/functions/bitwise.ts:75
Helper function to get the value of a specific but in a binary representation of a number.
Parameters
Section titled “Parameters”int
int
Returns
Section titled “Returns”int
getNumBitsOfN()
Section titled “getNumBitsOfN()”getNumBitsOfN(
n):int
Defined in: packages/isaacscript-common/src/functions/bitwise.ts:80
Helper function to get the number of bits in a binary representation of a number.
Parameters
Section titled “Parameters”int
Returns
Section titled “Returns”int
setToBitFlags()
Section titled “setToBitFlags()”setToBitFlags<
T>(set):BitFlags<T>
Defined in: packages/isaacscript-common/src/functions/bitwise.ts:91
Helper function to convert a set of flags to a single BitFlags object.
Type Parameters
Section titled “Type Parameters”T extends BitFlag | BitFlag128
Parameters
Section titled “Parameters”ReadonlySet<T>
Returns
Section titled “Returns”BitFlags<T>
