|
Boost Users : |
Subject: [Boost-users] [Rational] "r.den > zero" assertion failure
From: Pierre Cagne (pierre.cagne_at_[hidden])
Date: 2011-07-13 05:16:16
Hi,
I'm having a weird dynamic failure using Boost.Rational.
Using some rationals and doing a calculus, i'm ending with a rational with a negative denominator, and so unusable for comparison (hence the r.den > 0 assertion failure during the execution).
More precisely, here is a piece of code : (with typedef boost::rational<mpz_class> rat)
std::cout << xa << " " << ya << " "
<< xb << " " << yb << " "
<< xc << " " << yc << " "
<< xd << " " << yd << std::endl;
// determinant
rat delta = (xb - xa)*(yc - yd) - (yb - ya)*(xc - xd);
std::cout << "Delta : " << delta << std::endl;
/* ... some comparisons on delta ...*/
For the following result :
0/1 1/4 1/2 0/1 0/1 0/1 1/1 0/1
Delta : 1/-4
Assertion failed: (r.den > zero), function operator<, file /usr/local/include/boost/rational.hpp, line 388.
How does it come that Boost does not maintain the assertion correct ? I precise that the same code with the type boost::rational<int> does not produce the failure.
Thankfully.
P.S. : i'm new on this mailing-list ; does my message match with the common pattern of this list ?
-- Pierre Cagne pierre.cagne_at_[hidden]
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net