The most efficient formula is to use bitwise and operation:
overflowed=value & 0xFF #for unsigned overflowed=((value + 128)&255)-128 #for signed