]>
Does anyone know if the hardware implementation of integer division
and/or remainder is faster because the returned value from remainder
is sometimes negative? Maybe its slower but everyone does it the same
way for backwards compatibility?
One reason for the hardware remainder to be positive is that it allows
for easier compiler optimizations. If the remainder is always
positive then the following transformations are always available:
M / (2**N) == M asr N
M mod (2**N) == M land (2**N-1)
I guess it doesn't much matter as this optimization is normally
applied to array indices which usually are non-negative anyway.
PS - i'm not sure if this trick also works with 1s complement
representation but when was the last time anyone built one of
those machines?
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr