@@ -105,11 +105,11 @@ function ceil(SD59x18 x) pure returns (SD59x18 result) {
105105/// values separately.
106106///
107107/// Notes:
108- /// - All from {Common.mulDiv}.
108+ /// - Refer to the notes in {Common.mulDiv}.
109109/// - The result is rounded toward zero.
110110///
111111/// Requirements:
112- /// - All from {Common.mulDiv}.
112+ /// - Refer to the requirements in {Common.mulDiv}.
113113/// - None of the inputs can be `MIN_SD59x18`.
114114/// - The denominator must not be zero.
115115/// - The result must fit in SD59x18.
@@ -133,7 +133,7 @@ function div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {
133133 yAbs = yInt < 0 ? uint256 (- yInt) : uint256 (yInt);
134134 }
135135
136- // Compute the absolute value (x*UNIT÷y). The resulting value must fit in int256 .
136+ // Compute the absolute value (x*UNIT÷y). The resulting value must fit in SD59x18 .
137137 uint256 resultAbs = Common.mulDiv (xAbs, uint256 (uUNIT), yAbs);
138138 if (resultAbs > uint256 (uMAX_SD59x18)) {
139139 revert Errors.PRBMath_SD59x18_Div_Overflow (x, y);
@@ -143,7 +143,7 @@ function div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {
143143 // negative, 0 for positive or zero).
144144 bool sameSign = (xInt ^ yInt) > - 1 ;
145145
146- // If the inputs don't have the same sign, the result should be negative . Otherwise, it should be positive .
146+ // If the inputs have the same sign, the result should be positive . Otherwise, it should be negative .
147147 unchecked {
148148 result = wrap (sameSign ? int256 (resultAbs) : - int256 (resultAbs));
149149 }
@@ -156,10 +156,10 @@ function div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {
156156/// $$
157157///
158158/// @dev Notes:
159- /// - All from {exp2}.
159+ /// - Refer to the notes in {exp2}.
160160///
161161/// Requirements:
162- /// - All from {exp2}.
162+ /// - Refer to the requirements in {exp2}.
163163/// - x must be less than 133_084258667509499441.
164164///
165165/// @param x The exponent as an SD59x18 number.
@@ -273,7 +273,7 @@ function frac(SD59x18 x) pure returns (SD59x18 result) {
273273/// - The result is rounded toward zero.
274274///
275275/// Requirements:
276- /// - x * y must fit in SD59x18, otherwise the result overflows .
276+ /// - x * y must fit in SD59x18.
277277/// - x * y must not be negative, since complex numbers are not supported.
278278///
279279/// @param x The first operand as an SD59x18 number.
@@ -299,7 +299,7 @@ function gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {
299299 revert Errors.PRBMath_SD59x18_Gm_NegativeProduct (x, y);
300300 }
301301
302- // We don't need to multiply the result by `UNIT` here because the x*y product had picked up a factor of `UNIT`
302+ // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`
303303 // during multiplication. See the comments in {Common.sqrt}.
304304 uint256 resultUint = Common.sqrt (uint256 (xyInt));
305305 result = wrap (int256 (resultUint));
@@ -328,11 +328,11 @@ function inv(SD59x18 x) pure returns (SD59x18 result) {
328328/// $$
329329///
330330/// @dev Notes:
331- /// - All from {log2}.
331+ /// - Refer to the notes in {log2}.
332332/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.
333333///
334334/// Requirements:
335- /// - All from {log2}.
335+ /// - Refer to the requirements in {log2}.
336336///
337337/// @param x The SD59x18 number for which to calculate the natural logarithm.
338338/// @return result The natural logarithm as an SD59x18 number.
@@ -352,10 +352,10 @@ function ln(SD59x18 x) pure returns (SD59x18 result) {
352352/// However, if x is an exact power of ten, a hard coded value is returned.
353353///
354354/// @dev Notes:
355- /// - All from {log2}.
355+ /// - Refer to the notes in {log2}.
356356///
357357/// Requirements:
358- /// - All from {log2}.
358+ /// - Refer to the requirements in {log2}.
359359///
360360/// @param x The SD59x18 number for which to calculate the common logarithm.
361361/// @return result The common logarithm as an SD59x18 number.
@@ -460,7 +460,7 @@ function log10(SD59x18 x) pure returns (SD59x18 result) {
460460
461461/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm.
462462///
463- /// For $0 \leq x < 1$, the logarithm is calculated as:
463+ /// For $0 \leq x \lt 1$, the logarithm is calculated as:
464464///
465465/// $$
466466/// log_2{x} = -log_2{\frac{1}{x}}
@@ -531,11 +531,10 @@ function log2(SD59x18 x) pure returns (SD59x18 result) {
531531/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.
532532///
533533/// @dev Notes:
534- /// - All from {Common.mulDiv18}.
535- /// - The result is rounded toward zero.
534+ /// - Refer to the notes in {Common.mulDiv18}.
536535///
537536/// Requirements:
538- /// - All from {Common.mulDiv18}.
537+ /// - Refer to the requirements in {Common.mulDiv18}.
539538/// - None of the inputs can be `MIN_SD59x18`.
540539/// - The result must fit in SD59x18.
541540///
@@ -558,6 +557,7 @@ function mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {
558557 yAbs = yInt < 0 ? uint256 (- yInt) : uint256 (yInt);
559558 }
560559
560+ // Compute the absolute value (x*y÷UNIT). The resulting value must fit in SD59x18.
561561 uint256 resultAbs = Common.mulDiv18 (xAbs, yAbs);
562562 if (resultAbs > uint256 (uMAX_SD59x18)) {
563563 revert Errors.PRBMath_SD59x18_Mul_Overflow (x, y);
@@ -567,7 +567,7 @@ function mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {
567567 // negative, 0 for positive or zero).
568568 bool sameSign = (xInt ^ yInt) > - 1 ;
569569
570- // If the inputs have the same sign, the result should be negative . Otherwise, it should be positive .
570+ // If the inputs have the same sign, the result should be positive . Otherwise, it should be negative .
571571 unchecked {
572572 result = wrap (sameSign ? int256 (resultAbs) : - int256 (resultAbs));
573573 }
@@ -580,11 +580,11 @@ function mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {
580580/// $$
581581///
582582/// @dev Notes:
583- /// - All from {exp2}, {log2}, and {mul}.
583+ /// - Refer to the notes in {exp2}, {log2}, and {mul}.
584584/// - Returns `UNIT` for 0^0.
585585///
586586/// Requirements:
587- /// - All from {exp2}, {log2}, and {mul}.
587+ /// - Refer to the requirements in {exp2}, {log2}, and {mul}.
588588///
589589/// @param x The base as an SD59x18 number.
590590/// @param y Exponent to raise x to, as an SD59x18 number
@@ -622,11 +622,11 @@ function pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {
622622/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.
623623///
624624/// Notes:
625- /// - All from {Common.mulDiv18}.
625+ /// - Refer to the notes in {Common.mulDiv18}.
626626/// - Returns `UNIT` for 0^0.
627627///
628628/// Requirements:
629- /// - All from {abs} and {Common.mulDiv18}.
629+ /// - Refer to the requirements in {abs} and {Common.mulDiv18}.
630630/// - The result must fit in SD59x18.
631631///
632632/// @param x The base as an SD59x18 number.
@@ -656,7 +656,7 @@ function powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {
656656 }
657657
658658 unchecked {
659- // Is the base negative and the exponent odd? If yes, the result is negative.
659+ // Is the base negative and the exponent odd? If yes, the result should be negative.
660660 int256 resultInt = int256 (resultAbs);
661661 bool isNegative = x.unwrap () < 0 && y & 1 == 1 ;
662662 if (isNegative) {
0 commit comments