Boost C++ Libraries: Ticket #12170: boost::multiprecision::export_bits throws on a negative cpp_int number https://svn.boost.org/trac10/ticket/12170 <p> When calling export_bits on a negative boost::multiprecision number based on cpp_int, an exception is thrown from the internal method msb ("testing individual bits in negative values is not supported"). </p> <p> boost::multiprecision::checked_int128_t i (-1); <em> use negative number std::vector&lt;unsigned char&gt; v; export_bits(i, std::back_inserter(v), 8); </em> throws </p> <p> export_bits is designed to be used for data exchange, so must export valid data. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12170 Trac 1.4.3 Tassilo Glander <tassilo.glander@…> Mon, 02 May 2016 08:54:26 GMT attachment set https://svn.boost.org/trac10/ticket/12170 https://svn.boost.org/trac10/ticket/12170 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">exportbits_negativeNumber.cpp</span> </li> </ul> Ticket John Maddock Mon, 02 May 2016 11:41:30 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/12170#comment:1 https://svn.boost.org/trac10/ticket/12170#comment:1 <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> Fixed as part of: <a class="ext-link" href="https://github.com/boostorg/multiprecision/commit/efbb9e272dba0cf03ed525e3de0292131f1dc378"><span class="icon">​</span>https://github.com/boostorg/multiprecision/commit/efbb9e272dba0cf03ed525e3de0292131f1dc378</a> </p> Ticket