+ 6

Symbol (^) in Java

What does this symbol ^ refer to ?

23rd Jan 2018, 12:12 PM
Learner
Learner - avatar
4 Respostas
+ 5
^ - bitwise operator XOR You can swap the bits of a number with it, to get a new number. Substraction and Addition: 1111 (15) ^ 0101 (5) = 1010 (10) 1010 (10) ^ 0101 (5) = 1111 (15) 1100 (12) ^ 0100 (4) = 1000 (8) 1000 (8) ^ 0100 (4) = 1100 (12)
23rd Jan 2018, 1:04 PM
Boris Batinkov
Boris Batinkov - avatar
+ 4
Prints counter i reversed: for (int i = 0; i < 16; i++) { System.out.println(i ^ 15); }
23rd Jan 2018, 1:18 PM
Boris Batinkov
Boris Batinkov - avatar
+ 3
Search for bitwise operators in Java. (^ refers to bitwise XOR) An example : https://www.tutorialspoint.com/java/java_bitwise_operators_examples.htm
23rd Jan 2018, 12:33 PM
Prokopios Poulimenos
Prokopios Poulimenos - avatar
+ 3
^ does not mean "power to" (that's what Math.pow(x,y) is for). ^ is the bitwise or, or logical or. https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.22
23rd Jan 2018, 12:33 PM
Physh
Physh - avatar