Paul Koning <pkoning(a)equallogic.com> wrote:
Then there are special cases: the Cray and Alpha
integer units, which
don't offer divide at all. Instead, you're supposed to multiply by
the reciprocal of the divisor.
Ahmm, but the reciprocal of an integer is not an integer, so you are
stepping out of integer-land into floating point territory. Do you
really want to use floating point to implement integer division
(dividing an integer by an integer to get quotient and remainder)?
And how do you guarantee that the final integer result will be exact?
(I guess you convert the dividend to a float, get the reciprocal of
the divisor, which will be a float, do float multiplication, and integerise
the result, right? Are there enough bits of precision in a float to
guarantee an exact result for integer division done this way? I
doubt that, since AFAIK Alpha has usual 32-bit and 64-bit floats,
which have other things besides mantissa in those bits, but has
64-bit integers.) And how do you get the remainder? Floating division
(whether direct or via multiplication by the reciprocal) doesn't produce
a remainder at all.
MS