Home > Back-end >  On Java bit operations
On Java bit operations

Time:10-09

Why the first write cycle by 8 and 9, results and expected,

If the program will be as a decimal number 11111110 (binary to decimal number 11111110? 101010011000101011000110?)

The result of the seven times in front of the circulation and how to explain things

CodePudding user response:

Default in the Java int value is a decimal, so you all in the first figure number is a decimal number, including print (I | 11111110) and the console are decimal,
As to the result of 1-7 and 8, 9, because, 1-7 is converted into binary with 11111110 converted into binary bitwise or after operation on the original figures (11111110) only add 1 or 0, 8 or 9 two number is converted to binary four digits, you'll see one conversion,
Directly to the digital markers for binary calculation:

CodePudding user response:

Was clear to yourself in a binary figure out
101010011000101011000110 | 00000000=101010011000101011000110//I=0
101010011000101011000110 | 00000001=101010011000101011000111//1
101010011000101011000110 | 00000010=101010011000101011000110//2
101010011000101011000110 | 00000011=101010011000101011000111//3
101010011000101011000110 | 00000100=101010011000101011000110//4
101010011000101011000110 | 00000101=101010011000101011000111//5
101010011000101011000110 | 00000110=101010011000101011000110//6
101010011000101011000110 | 00000111=101010011000101011000111//7
10101001100010101100 0 110 | 0000 1 1
810101001100010101100 0 111 | 0000 1 =10101001100010101100> 1 1
//9
Only the binary 0 and 1, 11111110 affected low 1
2-3, 11111110 only binary low two affected
4 to 7, 11111110 only binary low three affected
Began 8, 11111110 binary low starting four affected, while 11111110 was the fourth is 0, affected into 1, so the effect will be more big

CodePudding user response:

Thanks to answer??????

CodePudding user response:

1/f, reference code smallholder response:
default in the Java int value is a decimal, so you all in the first figure number is a decimal number, including print (I | 11111110) and the console are decimal,
As to the result of 1-7 and 8, 9, because, 1-7 is converted into binary with 11111110 converted into binary bitwise or after operation on the original figures (11111110) only add 1 or 0, 8 or 9 two number is converted to binary four digits, you'll see one conversion,
Directly to the digital markers for binary calculation:

Thanks to answer??????

CodePudding user response:

refer to the second floor qybao response:
was clear to yourself in a binary figure out
101010011000101011000110 | 00000000=101010011000101011000110//I=0
101010011000101011000110 | 00000001=101010011000101011000111//1
101010011000101011000110 | 00000010=101010011000101011000110//2
101010011000101011000110 | 00000011=101010011000101011000111//3
101010011000101011000110 | 00000100=101010011000101011000110//4
101010011000101011000110 | 00000101=101010011000101011000111//5
101010011000101011000110 | 00000110=101010011000101011000110//6
101010011000101011000110 | 00000111=101010011000101011000111//7
10101001100010101100 0 110 | 0000 1 1
810101001100010101100 0 111 | 0000 1 =10101001100010101100> 1 1
//9
Only the binary 0 and 1, 11111110 affected low 1
2-3, 11111110 only binary low two affected
4 to 7, 11111110 only binary low three affected
Start 8, 11111110 binary low four began to be affected, and 11111110 had 4 is 0, affected into 1, so the effect will be great

Thanks to answer??????
  • Related