forked from Uniswap/v3-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBitMathTest.sol
More file actions
26 lines (21 loc) · 812 Bytes
/
Copy pathBitMathTest.sol
File metadata and controls
26 lines (21 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
import '../libraries/BitMath.sol';
contract BitMathTest {
function mostSignificantBit(uint256 x) external pure returns (uint8 r) {
return BitMath.mostSignificantBit(x);
}
function getGasCostOfMostSignificantBit(uint256 x) external view returns (uint256) {
uint256 gasBefore = gasleft();
BitMath.mostSignificantBit(x);
return gasBefore - gasleft();
}
function leastSignificantBit(uint256 x) external pure returns (uint8 r) {
return BitMath.leastSignificantBit(x);
}
function getGasCostOfLeastSignificantBit(uint256 x) external view returns (uint256) {
uint256 gasBefore = gasleft();
BitMath.leastSignificantBit(x);
return gasBefore - gasleft();
}
}