Looks like JavaScript, feels like Ruby, and it is a script language fitting in C programmers.
This project is maintained by Kray-G
Bit AND operator will set 1 when both bits are 1 for each bit.
var a = 0x05;
var b = a | 0x06; // 0101 | 0110 => 0100
This can be also used with assignment operator as &=
.
var a = 0x05;
a &= 0x06; // 0101 | 0110 => 0100
Note that Bit OR operator will treat null
as 0.
function test(a, b) {
return a & b;
}
System.println(test(0x05, 0x06).toString(16));
System.println(test(11, 1).toString(16));
System.println(test(null, 0x05).toString(16));
System.println(test(0x07, null).toString(16));
4
1
0
0
function test(a, b) {
a &= b;
return a;
}
System.println(test(0x05, 0x06).toString(16));
System.println(test(11, 1).toString(16));
System.println(test(null, 0x05).toString(16));
System.println(test(0x07, null).toString(16));
4
1
0
0
function test(a, b) {
a &= b;
return a;
}
System.println(test(0x7fffffffffffffff + 4, 0x02).toString(16));
System.println(test(0x02, 0x7fffffffffffffff + 4).toString(16));
System.println(test(0x7fffffffffffffff * 2, 0x7fffffffffffffff * 4).toString(16));
2
2
fffffffffffffffc