-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d58054d
commit 6dd4275
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.26; | ||
|
||
// Unsigned | ||
import { UD60x18, ud } from "@prb/math/src/UD60x18.sol"; | ||
// // Signed | ||
// import { SD59x18, sd } from "@prb/math/src/SD59x18.sol"; | ||
|
||
contract pbrMathLogTesting { | ||
|
||
/// @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) | ||
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). | ||
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(); | ||
} | ||
|
||
} |