UIntMath
Author: M^0 Labs
Functions
safe16
Casts a given uint256 value to a uint16, ensuring that it is less than or equal to the maximum uint16 value.
Parameters
Name | Type | Description |
---|---|---|
|
| The value to check. |
Returns
Name | Type | Description |
---|---|---|
|
| The value casted to uint16. |
safe40
Casts a given uint256 value to a uint40, ensuring that it is less than or equal to the maximum uint40 value.
Parameters
Name | Type | Description |
---|---|---|
|
| The value to check. |
Returns
Name | Type | Description |
---|---|---|
|
| The value casted to uint40. |
safe48
Casts a given uint256 value to a uint48, ensuring that it is less than or equal to the maximum uint48 value.
Parameters
Name | Type | Description |
---|---|---|
|
| The value to check. |
Returns
Name | Type | Description |
---|---|---|
|
| The value casted to uint48. |
safe112
Casts a given uint256 value to a uint112, ensuring that it is less than or equal to the maximum uint112 value.
Parameters
Name | Type | Description |
---|---|---|
|
| The value to check. |
Returns
Name | Type | Description |
---|---|---|
|
| The value casted to uint112. |
safe128
Casts a given uint256 value to a uint128, ensuring that it is less than or equal to the maximum uint128 value.
Parameters
Name | Type | Description |
---|---|---|
|
| The value to check. |
Returns
Name | Type | Description |
---|---|---|
|
| The value casted to uint128. |
safe240
Casts a given uint256 value to a uint240, ensuring that it is less than or equal to the maximum uint240 value.
Parameters
Name | Type | Description |
---|---|---|
|
| The value to check. |
Returns
Name | Type | Description |
---|---|---|
|
| The value casted to uint240. |
bound32
Limits a given uint256 value to the maximum uint32 value.
Parameters
Name | Type | Description |
---|---|---|
|
| The value to check. |
Returns
Name | Type | Description |
---|---|---|
|
| The value limited to within uint32 bounds. |
bound112
Limits a given uint256 value to the maximum uint112 value.
Parameters
Name | Type | Description |
---|---|---|
|
| The value to check. |
Returns
Name | Type | Description |
---|---|---|
|
| The value limited to within uint112 bounds. |
bound128
Limits a given uint256 value to the maximum uint128 value.
Parameters
Name | Type | Description |
---|---|---|
|
| The value to check. |
Returns
Name | Type | Description |
---|---|---|
|
| The value limited to within uint128 bounds. |
bound240
Limits a given uint256 value to the maximum uint240 value.
Parameters
Name | Type | Description |
---|---|---|
|
| The value to check. |
Returns
Name | Type | Description |
---|---|---|
|
| The value limited to within uint240 bounds. |
max32
Compares two uint32 values and returns the larger one.
Parameters
Name | Type | Description |
---|---|---|
|
| Value to check. |
|
| Value to check. |
Returns
Name | Type | Description |
---|---|---|
|
| The larger value. |
max40
Compares two uint40 values and returns the larger one.
Parameters
Name | Type | Description |
---|---|---|
|
| Value to check. |
|
| Value to check. |
Returns
Name | Type | Description |
---|---|---|
|
| The larger value. |
min32
Compares two uint32 values and returns the lesser one.
Parameters
Name | Type | Description |
---|---|---|
|
| Value to check. |
|
| Value to check. |
Returns
Name | Type | Description |
---|---|---|
|
| The lesser value. |
min40
Compares two uint40 values and returns the lesser one.
Parameters
Name | Type | Description |
---|---|---|
|
| Value to check. |
|
| Value to check. |
Returns
Name | Type | Description |
---|---|---|
|
| The lesser value. |
min240
Compares two uint240 values and returns the lesser one.
Parameters
Name | Type | Description |
---|---|---|
|
| Value to check. |
|
| Value to check. |
Returns
Name | Type | Description |
---|---|---|
|
| The lesser value. |
min112
Compares two uint112 values and returns the lesser one.
Parameters
Name | Type | Description |
---|---|---|
|
| Value to check. |
|
| Value to check. |
Returns
Name | Type | Description |
---|---|---|
|
| The lesser value. |
min256
Compares two uint256 values and returns the lesser one.
Parameters
Name | Type | Description |
---|---|---|
|
| Value to check. |
|
| Value to check. |
Returns
Name | Type | Description |
---|---|---|
|
| The lesser value. |
Errors
InvalidUInt16
Emitted when a passed value is greater than the maximum value of uint16.
InvalidUInt40
Emitted when a passed value is greater than the maximum value of uint40.
InvalidUInt48
Emitted when a passed value is greater than the maximum value of uint48.
InvalidUInt112
Emitted when a passed value is greater than the maximum value of uint112.
InvalidUInt128
Emitted when a passed value is greater than the maximum value of uint128.
InvalidUInt240
Emitted when a passed value is greater than the maximum value of uint240.