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