Number utility methods.
Members
(static) MAX_UINT8 :number
Maximum value for unsigned 8-bit integer.
- Source:
Type:
-
number
(static) MAX_UINT16 :number
Maximum value for unsigned 16-bit integer.
- Source:
Type:
-
number
(static) MAX_UINT32 :number
Maximum value for unsigned 32-bit integer.
- Source:
Type:
-
number
Methods
(static) random(min, max) → {number}
Returns a random integer greater than or equal to
min
and
less than or equal max
.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
min |
number
|
The lower bound for the random integer. |
max |
number
|
The upper bound for the random integer. |
Returns:
- Type:
-
number
Returns a random integer.
(static) uint8(number) → {number}
Converts given
number
to unsigned int8.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
number |
number
|
The number to be converted. |
Returns:
- Type:
-
number
The unsigned (zero or positive) number.
Example
import { uint8 } from 'uint';
uint8(0); //> 0
uint8(1); //> 1
uint8(255); //> 255
uint8(-5); //> NaN
(static) uint16(number) → {number}
Converts given
number
to unsigned int16.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
number |
number
|
The number to be converted. |
Returns:
- Type:
-
number
The unsigned (zero or positive) number.
Example
import { uint16 } from 'uint';
uint16(0); //> 0
uint16(1); //> 1
uint16(65535); //> 65535
uint16(-5); //> NaN
(static) uint32(number) → {number}
Converts given
number
to unsigned int32.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
number |
number
|
The number to be converted. |
Returns:
- Type:
-
number
The unsigned (zero or positive) number.
Example
import { uint32 } from 'uint';
uint32(0); //> 0
uint32(1); //> 1
uint32(4294967295); //> 4294967295
uint32(-5); //> NaN