Boost logo

Boost :

From: SourceForge.net (noreply_at_[hidden])
Date: 2006-02-25 13:54:46


Patches item #1438626, was opened at 2006-02-25 06:49
Message generated for change (Settings changed) made by mclow
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=307586&aid=1438626&group_id=7586

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: David Benbennick (dbenbenn)
>Assigned to: Jonathan Turkanis (turkanis)
Summary: rational.hpp::gcd returns a negative value sometimes

Initial Comment:
boost/rational.hpp provides a gcd function, which is
supposed to be non-negative. It sometimes returns a
negative value, which can cause problems in other parts
of rational.hpp. For example, assuming long is a
4-byte type,

boost::gcd<long>(6, -2147483648)

returns -2. As a result,

boost::rational<long>(-1073741821, 6) +
boost::rational<long>(-1073741827, 6)

produces an invalid rational number, 1073741824/-3,
instead of the correct answer -1073741824/3.

Here is a small patch to fix the problem. Note that
this is how boost/math/common_factor_rt.hpp calculates
the greatest common divisor.

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=307586&aid=1438626&group_id=7586

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Boost-bugs mailing list
Boost-bugs_at_[hidden]
https://lists.sourceforge.net/lists/listinfo/boost-bugs


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