Re: Modulus problem



In article <1168902900.735078.197550@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
<zacariaz@xxxxxxxxx> wrote:
Im not sure this is the right place to ask.

Well basicly i need to know if one (potenitial very small positive)
integer divides up into another (potential very large positive)
integer.

When you say "very large", how large do you mean? It sounds like
you're talking about something that might fit in the "int" data type
of C; mathematicians would typically not consider that to be large at
all.

Normaly you would just divide and check if a remainder is present,
however i cant do that. The reason you ask? Well its somewhat tricky to
explain, but im doing some very low level programming, called assembly,
and the only way for me to get the modulus is to use the actual divide
instruction, as there is no standalone modulus instruction. This DIV
instruction as it is called, is very slow, and i would love to figure
out another way. The thing is that i dont really need to know, i just
need a boolean output telling me wether there is a remainder or not.

I was thinking if it would be posible to do some boolean manipulation
or other stuff.

Well, i hope someone can be of help, atleast confirming or deconfirming
wether it can be done or not.

Lookup tables may help. For example, suppose your "large" number x
could be up to 2^32, while your "small" number is y, and you have a
table of z mod y for 0 <= z <= 2^16. By taking the first and last
16 bits of x, you represent x = a + 2^16 * b where 0 <= a, b < 2^16,
and then (x mod y) = ((a mod y) + (2^16 mod y) * (b mod y)) mod y.

Robert Israel israel@xxxxxxxxxxx
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia Vancouver, BC, Canada
.



Relevant Pages

  • Re: Modulus problem
    ... integer divides up into another ... instruction, as there is no standalone modulus instruction. ... need a boolean output telling me wether there is a remainder or not. ...
    (sci.math)
  • Modulus problem
    ... integer divides up into another ... Normaly you would just divide and check if a remainder is present, ... instruction, as there is no standalone modulus instruction. ... need a boolean output telling me wether there is a remainder or not. ...
    (sci.math)