Your Try GMP! page
Linas Vepstas
linas at austin.ibm.com
Thu Jan 11 18:22:17 CET 2007
On Wed, Jan 10, 2007 at 09:43:08PM -0800, tonybrown at cox.net wrote:
> So, I reverted back to my basic number theory, any number should be expressible as
> n = qk + r where q=quotient and r=remainder.
>
> When I divide with your GMP, you don't provide the remainder of the division. However, taking simpler numbers, lets say we want to divide 7/4. My take on this is as follows, using n=qk+r:
>
> the sign of the quotient is the XOR of the signs of the dividend and divisor, so for example,
>
> -7/4 : quotient is -1 and if -7 = -1(k) + r , then k must be 4 and r must be -3
I can't speak for the design decisions that GMP has, but it is a common
assumption among working mathematicians that 0<= r < q i.e. that r is
positive. I beleive this explains what you're seeing.
--linas
More information about the gmp-discuss
mailing list