solidity/test/libsolidity/gasTests/exp_optimized.sol
2021-04-22 16:54:02 +02:00

30 lines
709 B
Solidity

pragma abicoder v2;
contract C {
function exp_neg_one(uint exponent) public returns(int) {
unchecked { return (-1)**exponent; }
}
function exp_two(uint exponent) public returns(uint) {
unchecked { return 2**exponent; }
}
function exp_zero(uint exponent) public returns(uint) {
unchecked { return 0**exponent; }
}
function exp_one(uint exponent) public returns(uint) {
unchecked { return 1**exponent; }
}
}
// ====
// optimize: true
// optimize-yul: true
// ----
// creation:
// codeDepositCost: 37200
// executionCost: 87
// totalCost: 37287
// external:
// exp_neg_one(uint256): 1917
// exp_one(uint256): 1870
// exp_two(uint256): 1848
// exp_zero(uint256): 1892