What happened when you tried it? Wouldn't that be the easiest way to find out what it does?

edit: Ah...Your subject is misleading.

The caret ^ is a bitwise OR operation.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors

Matthew Brown

Bartender

Posts: 4568

9

posted 5 years ago

Just to clarify, it's an exclusive-OR operation (or XOR). | is the bitwise inclusive OR.

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 ints, 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