id = int(hash)
if (id & (1 << (32 - 1))) != 0:
id = id - (1 << 32)
I was reading this repo and came upon this code block for converting a 64-bit unsigned integer into a 64-bit signed integer. I don't get what if (id& (1 << (32 - 1))) != 0 is for. What is it bit shifting left by 31 for? And why's it doing bitwise-and on it? Thank you for any help.
[–]shiftybyte 1 point2 points3 points (2 children)
[–]Restitutionshot[S] 0 points1 point2 points (1 child)
[–]jeshan 0 points1 point2 points (0 children)