solidity/test/libsolidity/gasTests/exp_optimized.sol

30 lines
709 B
Solidity
Raw Normal View History

2020-11-23 18:06:44 +00:00
pragma abicoder v2;
2020-09-25 15:05:15 +00:00
contract C {
function exp_neg_one(uint exponent) public returns(int) {
2020-09-15 14:16:30 +00:00
unchecked { return (-1)**exponent; }
2020-09-25 15:05:15 +00:00
}
function exp_two(uint exponent) public returns(uint) {
2020-09-15 14:16:30 +00:00
unchecked { return 2**exponent; }
2020-09-25 15:05:15 +00:00
}
function exp_zero(uint exponent) public returns(uint) {
2020-09-15 14:16:30 +00:00
unchecked { return 0**exponent; }
2020-09-25 15:05:15 +00:00
}
function exp_one(uint exponent) public returns(uint) {
2020-09-15 14:16:30 +00:00
unchecked { return 1**exponent; }
2020-09-25 15:05:15 +00:00
}
}
// ====
// optimize: true
// optimize-yul: true
// ----
// creation:
2021-01-14 12:02:14 +00:00
// codeDepositCost: 47800
// executionCost: 99
// totalCost: 47899
2020-09-25 15:05:15 +00:00
// external:
2021-01-14 12:02:14 +00:00
// exp_neg_one(uint256): 1917
// exp_one(uint256): 1870
// exp_two(uint256): 1848
// exp_zero(uint256): 1892