Looks like JavaScript, feels like Ruby, and it is a script language fitting in C programmers.
This project is maintained by Kray-G
+
and -
operators are showing of addition and subtraction operations.
Those operators will automatically make it promote to Big Integer when it is over 64 bit integer range.
var a = 10;
var b = a + 1; // 10 + 1 => 11
var c = 0x7fffffffffffffff + a; // 0x7fffffffffffffff + 10 => 0x8000000000000009
This can be also used with assignment operator as +=
or -=
.
var a = 0x05;
a += 0x06; // 5 + 6 => 11
Note that those operators will treat null
as 0.
function test(a, b) {
return a + b;
}
System.println(test(0x05, 1));
System.println(test(10, -2048));
System.println(test(null, 0x05));
System.println(test(0x07, null));
6
-2038
5
7
function test(a, b) {
return a - b;
}
System.println(test(0x05, 1));
System.println(test(10, -2048));
System.println(test(null, 0x05));
System.println(test(0x07, null));
4
2058
-5
7
function test(a, b) {
return (a + b).toString(16);
}
System.println(test(0x7fffffffffffffff, 2));
System.println(test(0x7fffffffffffffff + 1, -2));
8000000000000001
7ffffffffffffffe
function test(a, b) {
return (a - b).toString(16);
}
System.println(test(0x7fffffffffffffff, -2));
System.println(test(0x7fffffffffffffff + 1, 2));
8000000000000001
7ffffffffffffffe