You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
441 B
18 lines
441 B
6 years ago
|
pragma solidity ^0.5.0;
|
||
|
|
||
|
contract Test {
|
||
|
function a() public {
|
||
|
assembly {
|
||
|
function power(base, exponent) -> result {
|
||
|
switch exponent
|
||
|
case 0 { result := 1 }
|
||
|
case 1 { result := base }
|
||
|
default {
|
||
|
result := power(mul(base, base), div(exponent, 2))
|
||
|
switch mod(exponent, 2)
|
||
|
case 1 { result := mul(base, result) }
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|