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 does 'adition mod 2 ^ 32'.
Why the code? Well, I would like to ask your help to create a function that does the opposite of this function, but I have difficulties. Help me understand how I can be doing this.
To best exemplify, I have the following number, 554900798. It is '9144835390', before adding the 2³² module. Well, I would like to turn the '554900798' to '9144835390' again. I hope it has become clear.
What can I be doing?
Thank you in advance.