0

Why print(5^4) shows 1

Why print(5^4) shows 1

2nd Oct 2021, 7:53 AM
Amit Solanki
4 Respuestas
+ 6
^ (xor) is a bitwise operator This is what's happening under the hood: 000000100 = 4 000000101 = 5 ^ will evaluate both values, if the bits are the same, 0 is returned, 1 vice versa. 000000001 = 1
2nd Oct 2021, 8:01 AM
Tim
Tim - avatar
+ 3
That helps. Thanks a lot
2nd Oct 2021, 8:02 AM
Amit Solanki
+ 2
Rik Wittkopp Thank you for the compliment
2nd Oct 2021, 9:00 AM
Tim
Tim - avatar
+ 1
Terel Great answer!
2nd Oct 2021, 8:51 AM
Rik Wittkopp
Rik Wittkopp - avatar
En tendencia hoy
.
1 Votes
What?
0 Votes
HTML
0 Votes
Web
0 Votes
Quiz duel
0 Votes
FRC Coding?
1 Votes
AI
2 Votes
help
0 Votes
APIs
1 Votes