I have two numbers:
num1 = 1
num2 = 1
And then someone applied a secret operation on them:
mask = 2**8 -1
secret = (num1 << 8) | (num2 & mask)
>>> 257
How can I do the opposite of the secret operation? to get from 257 to 1 1
this is a standard way of encoding 2 small integers into a larger one
its 16bits of data representing 2 8 bit integers
to get the first one (upper 8 bits) back you shift it the other way
256 >> 8
to get the lower 8 bits just and it with the original mask
256 & (2**8-1)
as mentioned in the comments most ints are int32 (32 bits, not 8) and you likely cannot recover num2 if its value was greater than 255, because 8 bits can only represent 0-255
as an aside I imagine most people would use (1<<8)-1 instead of 2**8-1
num2if it is greater than 255, as the mask will erase the high bits in the original.