fix undefined shift of 1<<31 on signed ints