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 ?

Thankfully

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

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