From a719b31ee9a07a2b2c47219a172df6f7e0b4648c Mon Sep 17 00:00:00 2001 From: MarcusWentz <52706599+MarcusWentz@users.noreply.github.com> Date: Tue, 24 Sep 2024 06:26:43 -0400 Subject: [PATCH] Update pbrMathLogarithmTesting.sol --- Contracts/pbrMathLogarithmTesting.sol | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Contracts/pbrMathLogarithmTesting.sol b/Contracts/pbrMathLogarithmTesting.sol index cebaec7..bb944da 100644 --- a/Contracts/pbrMathLogarithmTesting.sol +++ b/Contracts/pbrMathLogarithmTesting.sol @@ -8,32 +8,33 @@ import { UD60x18, ud } from "@prb/math/src/UD60x18.sol"; contract pbrMathLogarithmTesting { + // For log2 and log10: + // Min input value for ud(x) is = 1 ether = 1000000000000000000 + // ud(1 ether) = x.log2() = x.log10() = 0 + // Reverts with 999999999999999999 + /// @notice Calculates the binary logarithm of the given signed number. - /// @dev Try this with x = 128e18. function unsignedLog2WithTenEther() external pure returns (UD60x18 result) { UD60x18 x = ud(10 ether); // Returns 3.321928094887362334 ether, since: - // 10 ether = 2**(3.321928094887362334 ether) + // 10 = (3.321928094887362334)**2 result = x.log2(); } /// @notice Calculates the binary logarithm of the given signed number. - /// @dev Try this with x = 128e18. function unsignedLog10WithTenEther() external pure returns (UD60x18 result) { UD60x18 x = ud(10 ether); // Returns 1 ether, since: - // 10 ether = 10**(1 ether). + // 10 = 1**(10). result = x.log10(); } /// @notice Calculates the binary logarithm of the given signed number. - /// @dev Try this with x = 128e18. function unsignedLog2(UD60x18 x) external pure returns (UD60x18 result) { result = x.log2(); } /// @notice Calculates the binary logarithm of the given signed number. - /// @dev Try this with x = 128e18. function unsignedLog10(UD60x18 x) external pure returns (UD60x18 result) { result = x.log10(); }