|
Boost : |
From: SourceForge.net (noreply_at_[hidden])
Date: 2006-02-19 16:24:39
Patches item #1434821, was opened at 2006-02-19 16:24
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=307586&aid=1434821&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: Nobody/Anonymous (nobody)
Summary: rational::operator< fails for unsigned value types
Initial Comment:
There's a minor bug in rational.hpp when using unsigned
values. Consider the following simple program:
int main(void) {
boost::rational<unsigned int> x = 0;
assert(x.operator<(1));
}
The assertion fails. The reason is that in
rational.hpp::rational<IntType>::operator< (param_type
i) are the lines
if (num > zero)
return (num/den) < i;
else
return -i < (-num/den);
The last line is bogus for unsigned types if num == 0
and i > 0. The problem can be fixed by changing (num >
zero) to (num >= zero).
Another issue with the same section of code is that it
uses up to 5 comparisons of IntType values. Attached
is a patch that fixes the bug described, and also makes
the function only perform up to 3 comparisons. That
can make a difference, of course, if IntType is a
complicated type with a slow comparison operator.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=307586&aid=1434821&group_id=7586
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&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