Brian Kenney

Greenhorn

Posts: 6

Matthew Brown

Bartender

Posts: 4568

9

Campbell Ritchie

Marshal

Posts: 55672

161

posted 5 years ago

- 1

You should find it in the Java Language Specification. That might not be easy to read, so let’s try without. Those numbers are

0x47 should be 0x00000047, which in binary is 0000_0000_0000_0000_0000_0000_0100_0111

0xa3 should be 0x000000a3, which in binary is 0000_0000_0000_0000_0000_0000_1010_0011

The exclusive or operator checks whether the two digits in the same location are the same (1^1 or 0^0), or different (1^0 or 0^1). It returns 1 for different and 0 for same. Putting those numbers together, we get

0000_0000_0000_0000_0000_0000_0100_0111

0000_0000_0000_0000_0000_0000_1110_0100

Voilà! 228 when it is converted to decimal.

`int`s, which occupy 32 bits (4 bytes) each.0x47 should be 0x00000047, which in binary is 0000_0000_0000_0000_0000_0000_0100_0111

0xa3 should be 0x000000a3, which in binary is 0000_0000_0000_0000_0000_0000_1010_0011

The exclusive or operator checks whether the two digits in the same location are the same (1^1 or 0^0), or different (1^0 or 0^1). It returns 1 for different and 0 for same. Putting those numbers together, we get

0000_0000_0000_0000_0000_0000_0100_0111

__0000_0000_0000_0000_0000_0000_1010_0011__0000_0000_0000_0000_0000_0000_1110_0100

Voilà! 228 when it is converted to decimal.