-
Notifications
You must be signed in to change notification settings - Fork 0
u32
dastal - v5.0.0 / u32
Bit hacks for 32-bit unsigned numbers.
▸ bitsSet(a
): number
Get the number of bits set of a 32-bit unsigned number (source)
Name | Type |
---|---|
a |
number |
number
▸ invert(a
): number
Invert the bits of a 32-bit unsigned number.
Example: 11 (1011) -> 4 (0100)
Name | Type | Description |
---|---|---|
a |
number |
The number to invert |
number
The inverted number
▸ isPow2(a
): boolean
Check whether a 32-bit unsigned number is a power of 2.
Example: 8 (1000) -> true
Name | Type | Description |
---|---|---|
a |
number |
The number to check |
boolean
▸ lsb(a
): number
Get the Least Significant Bit of a 32-bit unsigned number
Name | Type |
---|---|
a |
number |
number
The lowest bit set
▸ lsp(a
): number
Get the Least Significant Power of a 32-bit unsigned number
Name | Type |
---|---|
a |
number |
number
2**lsb(a)
▸ lsps(a
): number
Get the Least Significant Power Set of a 32-bit unsigned number.
Example: 54 (110110) -> 6 (000110)
Name | Type |
---|---|
a |
number |
number
▸ lzb(a
): number
Get the Least Zeroed Bit of a 32-bit unsigned number
Name | Type |
---|---|
a |
number |
number
▸ lzp(a
): number
Get the Least Zeroed Power of a 32-bit unsigned number
Name | Type |
---|---|
a |
number |
number
2**lzb(a)
▸ msb(a
): number
Get the Most Significant Bit of a 32-bit unsigned number
Name | Type |
---|---|
a |
number |
number
⌊log2(a)⌋ : the highest bit set
▸ msp(a
): number
Get the Most Significant Power of a 32-bit unsigned number
Name | Type |
---|---|
a |
number |
number
2**msb(a)
▸ msps(a
): number
Get the Most Significant Power Set of a 32-bit unsigned number.
Example: 50 (110010) -> 48 (110000)
Name | Type |
---|---|
a |
number |
number
▸ reverse(a
): number
Reverse a 32-bit unsigned number.
Example: 50 (110010) -> 19 (010011)
Name | Type |
---|---|
a |
number |
number
▸ u32(a
): number
Turn a number into an unsigned 32-bit number
Name | Type |
---|---|
a |
number |
number