Methods
(static) clear(num, bit) → {number}
Set a specific bit to 0
Example
Bit.clear(446, 3);
//423
Parameters:
Name | Type | Description |
---|---|---|
num |
number | |
bit |
number | bit index |
Returns:
- Type
- number
(static) find(num, bit) → {number}
Flip the state of a bit
Example
Bit.find(438, 3);
//446
Parameters:
Name | Type | Description |
---|---|---|
num |
number | |
bit |
number | bit index |
Returns:
- Type
- number
(static) find(num, bit) → {number}
Find the state of a bit
Example
Bit.find(438, 3);
//0
Parameters:
Name | Type | Description |
---|---|---|
num |
number | |
bit |
number | bit index |
Returns:
- Type
- number
(static) reverse(num, full) → {number}
Reverse order of bit
Example
Bit.reverse(446, 3);
//251
Parameters:
Name | Type | Description |
---|---|---|
num |
number | |
full |
number | if full int32 |
Returns:
- Type
- number
(static) rol(num, count, sizeopt) → {number}
Rotate order of bit to the left
Example
Bit.rol(446, 3);
//502
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
num |
number | ||
count |
number | ||
size |
number |
<optional> |
default is size of num |
Returns:
- Type
- number
(static) ror(num, count, sizeopt) → {number}
Rotate order of bit to the right
Example
Bit.ror(446, 3);
//439
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
num |
number | ||
count |
number | ||
size |
number |
<optional> |
default is size of num |
Returns:
- Type
- number
(static) set(num, bit) → {number}
Set a specific bit to 1
Example
Bit.set(423, 3);
//446
Parameters:
Name | Type | Description |
---|---|---|
num |
number | |
bit |
number | bit index |
Returns:
- Type
- number
(static) size(num, accuracyopt) → {number}
Get bit size of a number
Example
Bit.size(446);
//9
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
num |
number | |||
accuracy |
boolean |
<optional> |
false
|
`true` if extend up to 53 bits |
Returns:
- Type
- number