Boost C++ Libraries: Ticket #8126: multiprecision, incorrect sign https://svn.boost.org/trac10/ticket/8126 <p> This program outputs "-1" instead of "1". </p> <p> Tested on 32-bit machine with GCC 4.7.2 and MSVC 2010 (boost 1.53.0). </p> <pre class="wiki"> #include &lt;iostream&gt; #include &lt;boost/multiprecision/cpp_int.hpp&gt; using boost::multiprecision::cpp_int; int main() { cpp_int a("-4294967296"); cpp_int b("4294967296"); cpp_int c("-1"); std::cout &lt;&lt; (a/b)*c &lt;&lt; '\n'; // prints "1" (correct) a = (a/b)*c; std::cout &lt;&lt; a; // prints "-1" (incorrect) return 0; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8126 Trac 1.4.3 Stepan Podoskin <stepik-777@…> Wed, 20 Feb 2013 21:44:29 GMT component changed; owner set https://svn.boost.org/trac10/ticket/8126#comment:1 https://svn.boost.org/trac10/ticket/8126#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">John Maddock</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">multiprecision</span> </li> </ul> Ticket John Maddock Thu, 21 Feb 2013 13:05:45 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/8126#comment:2 https://svn.boost.org/trac10/ticket/8126#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/83060" title="Fix sign of division in cpp_int when the values are small enough to ...">[83060]</a>) Fix sign of division in cpp_int when the values are small enough to fit in a double_limb_type. Add test cases for above. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8126" title="#8126: Bugs: multiprecision, incorrect sign (closed: fixed)">#8126</a>. </p> Ticket Stepan Podoskin <stepik-777@…> Thu, 21 Feb 2013 14:03:59 GMT <link>https://svn.boost.org/trac10/ticket/8126#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8126#comment:3</guid> <description> <p> You fixed that case but here is another one that stil doesn't work. </p> <pre class="wiki"> cpp_int a("-26607734784073568386365259775"); cpp_int b("8589934592"); a = a/b; std::cout &lt;&lt; a; // outputs 3097548007973652377 </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Thu, 21 Feb 2013 18:34:06 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/8126#comment:4 https://svn.boost.org/trac10/ticket/8126#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> Not only that one actually, there's a whole bunch of divide and and modulus operators that don't behave correctly when source and destination are the same. </p> <p> Testing some new fixes now... </p> Ticket John Maddock Fri, 22 Feb 2013 10:37:38 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/8126#comment:5 https://svn.boost.org/trac10/ticket/8126#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/83080" title="Fix bug in subtraction of a limb_type. Fix bug in division/modulus ...">[83080]</a>) Fix bug in subtraction of a limb_type. Fix bug in division/modulus algorithms that results in incorrect sign when source and destination overlap. Tweak performance of GCD algorithms. Add test cases for bug reports. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8133" title="#8133: Bugs: multiprecision, failed gcd tests (test_cpp_int.cpp) (closed: fixed)">#8133</a>. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8126" title="#8126: Bugs: multiprecision, incorrect sign (closed: fixed)">#8126</a>. </p> Ticket