[OT] Bit twiddling homework

jladasky at itu.edu jladasky at itu.edu
Fri Jul 20 14:15:30 EDT 2018


On Friday, July 20, 2018 at 2:00:26 AM UTC-7, Brian Oney wrote:

> Are 16|1 and 16+1 internally the same operation (for integers)?

For 16 and 1, the output of the two operations happen to be the same, but generally a bitwise OR is not the same are addition.  There are no carry bits in the bitwise operation!  1 + 1 = 2.  But 1 | 1 = 1.


More information about the Python-list mailing list