
First there is no A % B operation which is const (boost::rational complained as it tries to do a mod operation on a const int_type.) I added one and got past this.
How does the function you added look like? I'm not sure I understand why you would want to do a mod operation on a constant type. a = b % c; // b and c are constant a %= b; // b is constant Both are supported.
During the normalization step of boost::rational the numerator and denominator are normalized by the gcd of the two. In one case I was testing the %= operator of mp_int<> was causing an infinite loop in the boost::math::gcd call. I made an attempt at a fix (though I didn't really spend much time on it.. so I'm not sure what if any side-effects) ... The case I had fail was when normalizing (-16384)/(16384). (-1/1). So it was infinite looping on boost::math::gcd( mp_int<>( -16384 ), mp_int<>( 16384 ) );
Is it possible for Boost.Rational to delegate to the mp_math::gcd (which should be faster than math::gcd)? mp_math::gcd handles mixed negative/positive numbers just fine.
double rational_cast( const boost::rational< boost::mp_math::mp_int<> >& src ) { ... }
I cannot confirm that you hit a bug here. While trying to see what is going on I discovered an unrelated bug in the to_string conversion using decimal output which happens in rare cases (it will swallow a midnumber zero when it lies on a certain boundary). Can you provide me with some starting values?