4 ms·
This is not specific to ARM. There is to my knowledge no CPU architecture where an arithmetic right shift works differently. Unsigned types allow the compiler
by mansr 16y ago
This is not specific to ARM. There is to my knowledge no CPU architecture where an arithmetic right shift works differently.
Unsigned types allow the compiler to perform this optimisation. However, unsigned types can easily introduce unexpected behaviours elsewhere. One of the more common is a comparison in which an unsigned wraparound where a negative result was expected causes the wrong branch to be taken.
If a value is known to be positive, one can always safely use a right shift directly rather than the division operator.