Bitwise
Functions
arrayToBitFlags
▸ arrayToBitFlags<T
>(array
): BitFlags
<T
>
Helper function to convert a set of flags to a single BitFlags
object.
Type parameters
Name | Type |
---|---|
T | extends BitFlag | BitFlag128 |
Parameters
Name | Type |
---|---|
array | readonly 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
Name | Type |
---|---|
bits | readonly 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
Name | Type | Description |
---|---|---|
num | number | The number to convert. |
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
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
Name | Type |
---|---|
num | int |
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
Name | Type |
---|---|
k | int |
n | int |
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
Name | Type |
---|---|
n | int |
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
Name | Type |
---|---|
T | extends BitFlag | BitFlag128 |
Parameters
Name | Type |
---|---|
set | ReadonlySet <T > |
Returns
BitFlags
<T
>