Linked Questions
75 questions linked to/from Bitwise operation and usage
44
votes
5
answers
73k
views
What does & mean in python [duplicate]
I came across the following code
numdigits = len(cardNumber)
oddeven = numdigits & 1
what exactly is going on here? I'm not sure what the "&" is doing.
-2
votes
2
answers
843
views
Bitwise or operator | usage in C for aligning memory blocks [duplicate]
I'm writing a memory manager in C and am trying to make sure it's properly aligned (make sure the user space starts on an address divisible by 8, and make sure the whole block is divisible by 8 as ...
0
votes
3
answers
385
views
if (index & 0x88) == 0, how this works? [duplicate]
Can anyone show me how this operation works? Index is number and it can be any number from 0 to 128. I just don't understand how (index & 0x88) can be 0 or not.
Any help will be greatly ...
0
votes
1
answer
424
views
When to use the bitwise and operator (&)? [duplicate]
I understand that the bitwise and operator (&) is equivalent to a product of two bit values. When would I use it?
I am also keen to understand what num&1 does in the code below:
def func(num):
...
-2
votes
1
answer
184
views
& Bit operation in python [duplicate]
In doing a bitwise &, I thought by specifying the digit it would add that digit in the necessary spot, but in python I get the following:
>>> 4&2
0
>>> 4&1<<1
0
&...
-6
votes
2
answers
319
views
C Bitwise operations [duplicate]
Possible Duplicate:
Bitwise Operation and Usage
x is the input. need to put either 0, 1, x, or x̅ :
x & 0 = 0
x & 1 = x
x | 0 = x
x | 1 = 0
x ^ 0 = 1
x ^ 1 =
1
vote
0
answers
265
views
What is a single bar in python? [duplicate]
I was reading a word count example for Apache beam when I saw this Python code
p | beam.io.ReadFromText(
'gs://dataflow-samples/shakespeare/kinglear.txt')
In this p is a already defined variable
...
0
votes
3
answers
98
views
Python comparison weirdness [duplicate]
I have an object that I need to compare some attributes of and I can't explain what is going on, but the following is the output of my VS code debugger (I added '=' before each output)
(0 > 55000 | ...
0
votes
0
answers
118
views
why 0x35014541 is output of xor eax, ebx? [duplicate]
`why 0x35014541 is output of xor eax, ebx? xor does not shows only 1 or 0?
**Register**
eax = 0xffffffff
ebx = 0xcafebabe
**Code**
xor eax, ebx
Output
eax = 0x35014541
Expected
1
0
votes
0
answers
105
views
How to change the least significant bit in Python [duplicate]
I'm new in Python and I would like to know how to change the least significant bit in Python.
I would like to do something like this:
mybytes = bytes(16) ## Creating the byte object filled with ...
0
votes
1
answer
70
views
what is behind the operator OR inside assignment operators? [duplicate]
i know the mechanics behind from operator OR, but in this case why the output is 7 ? what is behind?
x = int(5)
x = x | 3
print(x)
Thanks.
-1
votes
1
answer
106
views
& operator with numbers [duplicate]
I found out something interesting in Python. When I input: 99 & 100 Out is 96. What does '&' do with these numbers? Why is the answer '96'? It looks so wierd...
Thank you in advance!
-1
votes
2
answers
86
views
What does if x: mean in Python [duplicate]
I have the following code segment in python
if mask & selectors.EVENT_READ:
recv_data = sock.recv(1024)
if recv_data:
data.outb += recv_data
else:
print(f"...
-7
votes
1
answer
88
views
Difference between & and and in python [duplicate]
year=1992
print (year%4==0 and (year%100==0 or year%400==0))
print (year%4==0 & (year%100==0 or year%400==0))
Why two output are not equal?
-3
votes
1
answer
65
views
| ,^, <<= , >>= Mathematical Operations in python [duplicate]
I have tried to find out about these operations in Python:
x|3
x^3
x>>=3
x<<=3
I couldn't find anything. Please can anyone tell me what are these operations are called, so that I can ...