-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue in Rmpq_z_div(r, z, q) when z=0 #3
Comments
From: Daniel Șuteu
Sent: Monday, April 17, 2017 9:31 AM
To: sisyphus/math-gmpq
Cc: Subscribed
Subject: [sisyphus/math-gmpq] Issue in Rmpq_z_div(r, z, q) when z=0 (#3)
Hi Rob,
There is a minor issue in Rmpq_z_div(r, z, q) when the z holds the value
0.
Duh ... probably shouldn't multiply a denominator by zero.
I think (untested) this will work correctly:
void Rmpq_z_div(mpq_t * rop, mpz_t * z, mpq_t * op) {
if(rop != op) mpq_set(*rop, *op);
mpq_inv(*rop, *rop);
mpz_mul(mpq_numref(*rop), mpq_numref(*rop), *z);
mpq_canonicalize(*rop);
}
But I also need to catch the "divide-by-zero" cases - in many (if not all)
of the division routines.
The ones I tested all crash on "divide-by-zero" which is not very helpful.
I expect that the above reworking of Rmpq_z_div will also crash if op is
zero, irrespective of the value of z.
I just need to insert code that calls a croak() whenever a "divide-by-zero"
is about to occur.
I'll do that over the next couple of days, write some tests that check that
"divide-by-zero" is being caught, and then push another release to CPAN.
Cheers,
Rob
|
I've just pushed Math-GMPq-0.45 to CPAN. |
Hi Rob, Fix confirmed here. Thank you very much. Regards, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Rob,
There is a minor issue in
Rmpq_z_div(r, z, q)
whenz
holds the value0
.Output:
The text was updated successfully, but these errors were encountered: