In C #, I can distinguish things from 8-bit signed ints like this:
(sbyte)arg1;
which arg1 = 2also returns 2. However, it is obvious that casting 128will return -128. More specifically, casting 251will return -5.
What is the best way to imitate this behavior?
Edit: duplicate question found: Typecasting in Python
s8 = (i + 2**7) % 2**8 - 2**7 // convert to signed 8-bit
source
share