Skip to content

Commit

Permalink
docs: fix incorrect comment
Browse files Browse the repository at this point in the history
  • Loading branch information
MerlinEgalite committed Nov 8, 2023
1 parent 76ca930 commit 1eff87c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/libraries/MathLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ library MathLib {
unchecked {
// Revert if x > ln(2^256-1) ~ 177.
require(x <= 177.44567822334599921 ether, ErrorsLib.WEXP_OVERFLOW);
// Return zero if x < -(2**255-1) + (ln(2)/2).
// Return zero if x < -2**255 + (ln(2)/2).
if (x < type(int256).min + LN2_INT / 2) return 0;

// Decompose x as x = q * ln(2) + r with q an integer and -ln(2)/2 <= r <= ln(2)/2.
// q = x / ln(2) rounded half toward zero.
int256 roundingAdjustment = (x < 0) ? -(LN2_INT / 2) : (LN2_INT / 2);
// Safe unchecked because x is bounded.
int256 q = (x + roundingAdjustment) / LN2_INT;
// Safe unchecked because |q * LN2_INT| <= |x|.
// Safe unchecked because |q * LN2_INT - x| <= LN2_INT/2.
int256 r = x - q * LN2_INT;

// Compute e^r with a 2nd-order Taylor polynomial.
// Safe unchecked because |r| < 1, expR < 2 and the sum is positive.
// Safe unchecked because |r| < 1e18, and the sum is positive.
uint256 expR = uint256(WAD_INT + r + (r * r) / WAD_INT / 2);

// Return e^x = 2^q * e^r.
Expand Down

0 comments on commit 1eff87c

Please sign in to comment.