Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2006-10-31 11:34:33


I just checked in a fix for bug #798357, which concerns boost::rational's
operator< overflowing. Can someone confirm the fix, especially on wacky
compilers (like MSVC 6)? The new test includes large numbers that are
relatively prime, which the old code couldn't handle. (The old code hoped
that partial cancellation would happen to lessen the component values.) I
want to close out the bug.

The old code used cross multiplication before integer comparisons, which can
overflow. The new code manually does the Euclidian GCD algorithm, since its
intermediate results give the continued fraction expansion. The components
of that expansion are compared, with the regular code ending when
corresponding components differ, and special code when one sequence ends
early (or both end simultaneously without a difference).

The changes are in "rational.hpp", "rational_test.cpp", and "rational.html"
(the performance descriptions for comparisons have changed).

-- 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT hotmail DOT com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk