Accumulator
Library to operate on the liquidation multiplier accumulator values (512-bit integers).
This is a wrapper for HugeUint that is deployed to its own address and called via delegatecall.
Functions
add
Calculates the sum a + b of two 512-bit unsigned integers.
function add(HugeUint.Uint512 memory a, HugeUint.Uint512 memory b)
external
pure
returns (HugeUint.Uint512 memory res_);
Parameters
| Name | Type | Description |
|---|---|---|
a | HugeUint.Uint512 | The first operand. |
b | HugeUint.Uint512 | The second operand. |
Returns
| Name | Type | Description |
|---|---|---|
res_ | HugeUint.Uint512 | The sum of a and b. |
sub
Calculates the difference a - b of two 512-bit unsigned integers.
function sub(HugeUint.Uint512 memory a, HugeUint.Uint512 memory b)
external
pure
returns (HugeUint.Uint512 memory res_);
Parameters
| Name | Type | Description |
|---|---|---|
a | HugeUint.Uint512 | The first operand. |
b | HugeUint.Uint512 | The second operand. |
Returns
| Name | Type | Description |
|---|---|---|
res_ | HugeUint.Uint512 | The difference a - b. |
mul
Calculates the product a * b of two 256-bit unsigned integers using the Chinese remainder theorem.
function mul(uint256 a, uint256 b) external pure returns (HugeUint.Uint512 memory res_);
Parameters
| Name | Type | Description |
|---|---|---|
a | uint256 | The first operand. |
b | uint256 | The second operand. |
Returns
| Name | Type | Description |
|---|---|---|
res_ | HugeUint.Uint512 | The product a * b of the operands as an unsigned 512-bit integer. |
mul
Calculates the product a * b of a 512-bit unsigned integer and a 256-bit unsigned integer.
function mul(HugeUint.Uint512 memory a, uint256 b) external pure returns (HugeUint.Uint512 memory res_);
Parameters
| Name | Type | Description |
|---|---|---|
a | HugeUint.Uint512 | The first operand. |
b | uint256 | The second operand. |
Returns
| Name | Type | Description |
|---|---|---|
res_ | HugeUint.Uint512 | The product a * b of the operands as an unsigned 512-bit integer. |
div
Calculates the division floor(a / b) of a 512-bit unsigned integer by an unsigned 256-bit integer.
function div(HugeUint.Uint512 memory a, uint256 b) external pure returns (uint256 res_);
Parameters
| Name | Type | Description |
|---|---|---|
a | HugeUint.Uint512 | The numerator as a 512-bit unsigned integer. |
b | uint256 | The denominator as a 256-bit unsigned integer. |
Returns
| Name | Type | Description |
|---|---|---|
res_ | uint256 | The division floor(a / b) of the operands as an unsigned 256-bit integer. |
div
Computes the division floor(a/b) of two 512-bit integers, knowing the result fits inside a uint256.
function div(HugeUint.Uint512 memory a, HugeUint.Uint512 memory b) external pure returns (uint256 res_);
Parameters
| Name | Type | Description |
|---|---|---|
a | HugeUint.Uint512 | The numerator as a 512-bit integer. |
b | HugeUint.Uint512 | The denominator as a 512-bit integer. |
Returns
| Name | Type | Description |
|---|---|---|
res_ | uint256 | The quotient floor(a/b). |