Boost logo

Boost Users :

Subject: Re: [Boost-users] [Rational] "r.den > zero" assertion failure
From: Pierre Cagne (pierre.cagne_at_[hidden])
Date: 2011-07-13 10:52:28

>> 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).

I've come to a trick : (with typedef boost::rational<mpz_class> rat)
  rat x = /* ... some calculus with variable of type rat ... */ ;
  x = rat(x.numerator(), x.denominator());

Well, this is'nt pretty. What's more, it implicates some operations of numbers of type mpz_class : so it takes time, and my program is greedy about it (it's a Bentley-Ottmann's algorithm on thousands of segment lines).

Any idea to avoid something that greedy ?


@Micheal Olea : honest mistake ;) Thanks for the interest.

Pierre Cagne

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at