0
def mod_2to32sub1(x):
s = 0 # the sum
while x > 0: # get the digits
s += x & (2**32-1)
x >>= 32
if s > 2**32-1:
return mod_2to32sub1(s)
elif s == 2**32-1:
return 0
else:
return s
This function above makes 'adition mod 2 32'.
What’s with the code? Well, I would ask for your help in creating a function that does the opposite of that function, but I have difficulties. Help me understand how I can be doing this.
To illustrate better, I have the following number, 554900798. It is '9144835390', before adding module 2³². Well, I’d like to turn '554900798' to '9144835390' again. I hope that’s clear.
What can I be doing?
Thanks in advance.
How does he make the "addition" of the addition definition predict two operands and one result? There only one operand is being passed
– Jefferson Quesado
One would be x and the other 0. The function is equivalent to '>>> 0' of Javascript. Only I wanted to understand if I can create an inverse function (<<). I was asked to do this in the course
– Isaque de Souza