Skip to content

Commit

Permalink
fix edge case where t1 = type(int256).min
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxx committed Jan 19, 2024
1 parent 0ad5cd4 commit 32fbe53
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion contracts/utils/math/Math.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

pragma solidity ^0.8.20;

import "./SignedMath.sol";

/**
* @dev Standard math utilities missing in the Solidity language.
*/
Expand Down Expand Up @@ -239,7 +241,7 @@ library Math {
(t1, t2, r2, r1) = (t2, t1 - t2 * int256(q), r1, r2 - r1 * q);
}
if (r2 != 1) return 0;
return t1 < 0 ? (p - uint256(-t1)) : uint256(t1);
return t1 < 0 ? p - SignedMath.abs(-t1) : uint256(t1);
}
}

Expand Down

0 comments on commit 32fbe53

Please sign in to comment.