Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 16743

bit-wise operation unary ~ (invert)

$
0
0

I'm a little confused by the ~ operator. Code goes below:

a = 1~a  #-2b = 15~b  #-16

How does ~ do work?

I thought, ~a would be something like:

0001 = a1110 = ~a 

why not?


Viewing all articles
Browse latest Browse all 16743

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>