Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Why would "0^5" evaluate to 5? (question 21)

And is there a way to link to a specific question?



^ is the XOR operator, 0 XOR 5 is 5. (Exponentiation is *)

https://docs.python.org/3/library/operator.html#mapping-oper...


Exponentiation is ** or pow()


xor




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: