[Bug libstdc++/47913] [C++0x] improve ratio_add to overflow less often
marc.glisse at normalesup dot org
gcc-bugzilla@gcc.gnu.org
Sun Feb 27 19:33:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47913
--- Comment #2 from Marc Glisse <marc.glisse at normalesup dot org> 2011-02-27 19:12:07 UTC ---
(In reply to comment #1)
> Looks like there is a pretty simple (eg, no continued fractions & co) way to do
> this:
The continued fraction thing for ratio_less may actually be easier:
- compare the integral parts
- if they are equal, remove that integer and compare the inverses
- have a terminating criterion (when denominators are 1?)
> http://www.boost.org/doc/libs/1_46_0/boost/rational.hpp
The runtime fraction addition in this file is what gcc currently does. I also
looked at ratio.hpp (and what it includes), which factors out the gcd of the
numerators and multiplies back with it at the end. That's a slight but fairly
limited improvement, I'm sure we can do better.
More information about the Gcc-bugs
mailing list