mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
27 lines
574 B
Solidity
27 lines
574 B
Solidity
type Int is int;
|
|
using {add as +, mul as *, unsub as -} for Int global;
|
|
|
|
function add(Int a, Int b) pure returns (Int) {
|
|
return Int.wrap(Int.unwrap(a) + Int.unwrap(b));
|
|
}
|
|
|
|
function mul(Int a, Int b) pure returns (Int) {
|
|
return Int.wrap(Int.unwrap(a) * Int.unwrap(b));
|
|
}
|
|
|
|
function unsub(Int a) pure returns (Int) {
|
|
return Int.wrap(-Int.unwrap(a));
|
|
}
|
|
|
|
function i(int x) pure suffix returns (Int) {
|
|
return Int.wrap(x);
|
|
}
|
|
|
|
contract C {
|
|
function test() public pure returns (Int) {
|
|
return - - -(4 i + 4 i * -3 i) * 2 i;
|
|
}
|
|
}
|
|
// ----
|
|
// test() -> 16
|