Wrap docstrings to 120 chars (#4600)
This commit is contained in:
@ -115,9 +115,10 @@ library Math {
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
|
||||
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
|
||||
* with further edits by Uniswap Labs also under MIT license.
|
||||
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
|
||||
* denominator == 0.
|
||||
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
|
||||
* Uniswap Labs also under MIT license.
|
||||
*/
|
||||
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
|
||||
unchecked {
|
||||
@ -159,8 +160,8 @@ library Math {
|
||||
prod0 := sub(prod0, remainder)
|
||||
}
|
||||
|
||||
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
|
||||
// See https://cs.stackexchange.com/q/138556/92363.
|
||||
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
|
||||
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
|
||||
|
||||
uint256 twos = denominator & (0 - denominator);
|
||||
assembly {
|
||||
@ -182,8 +183,8 @@ library Math {
|
||||
// four bits. That is, denominator * inv = 1 mod 2^4.
|
||||
uint256 inverse = (3 * denominator) ^ 2;
|
||||
|
||||
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
|
||||
// in modular arithmetic, doubling the correct bits in each step.
|
||||
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
|
||||
// works in modular arithmetic, doubling the correct bits in each step.
|
||||
inverse *= 2 - denominator * inverse; // inverse mod 2^8
|
||||
inverse *= 2 - denominator * inverse; // inverse mod 2^16
|
||||
inverse *= 2 - denominator * inverse; // inverse mod 2^32
|
||||
|
||||
Reference in New Issue
Block a user