-5

Can't seem to find a definition anywhere.

Typing into the console I can see...

  5^4 = 1
  5^3 = 6
  5^2 = 7

Any ideas why?

Seamus.Reeve
  • 120
  • 9
  • looks like the bitwise [XOR operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_XOR) – Rhayene Sep 22 '19 at 23:23

1 Answers1

1

It's a bitwise operation, ^ specifically does a XOR operation on the numbers.

XOR truth table
+-------------------+
|  a  |  b  | a ^ b |
+-------------------+
|  0  |  0  |   0   |
|  0  |  1  |   1   |
|  1  |  0  |   1   |
|  1  |  1  |   0   |
+-------------------+
00001001 -> 5
00001000 -> 4
--------
00000001 -> 1
00001001 -> 5
00000011 -> 3
--------
00001010 -> 6
00001001 -> 5
00000010 -> 2
--------
00001011 -> 7
kevinSpaceyIsKeyserSöze
  • 2,122
  • 1
  • 15
  • 19
d4vsanchez
  • 1,274
  • 1
  • 11
  • 22