Skip to content

Commit

Permalink
Fixed typos in Math: sqrt function. (OpenZeppelin#3522)
Browse files Browse the repository at this point in the history
  • Loading branch information
ronhuafeng committed Sep 9, 2022
1 parent 6746516 commit dc7ba09
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions contracts/utils/math/Math.sol
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ library Math {
}

/**
* @dev Returns the square root of a number. It the number is not a perfect square, the value is rounded down.
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
Expand All @@ -165,8 +165,8 @@ library Math {
// `msb(a) <= a < 2*msb(a)`.
// We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.
// This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.
// Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a
// good first aproximation of `sqrt(a)` with at least 1 correct bit.
// Using an algorithm similar to the msb computation, we are able to compute `result = 2**(k/2)` which is a
// good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1;
uint256 x = a;
if (x >> 128 > 0) {
Expand Down

0 comments on commit dc7ba09

Please sign in to comment.