Optimize the floor to shift transform.

Rewrite the parts that could cause overflow on signed or
unsigned words.
TODO: Similar optimisation for ceiling.
Optimize ceiling to shift transform.

Put the correction after the shift so that it
doesn't overflow.