Boost C++ Libraries: Ticket #8745: stream operator << for number/cpp_int_backend with 8 bit or less precision not working https://svn.boost.org/trac10/ticket/8745 <p> for 8 bit or less numbers &lt;&lt; with hex format sets characters to the numeric value of their digit rather than the ascii value. ie if the character should be 'F' the returned value is 15 rather than the ASCII value for F. </p> <blockquote> <p> number&lt;cpp_int_backend&lt;7, 7, unsigned_magnitude, unchecked, void&gt;&gt; myNum07( "0xF"); number&lt;cpp_int_backend&lt;8, 8, unsigned_magnitude, unchecked, void&gt;&gt; myNum08( "0x0F"); number&lt;cpp_int_backend&lt;9, 9, unsigned_magnitude, unchecked, void&gt;&gt; myNum09( "0x0F"); number&lt;cpp_int_backend&lt;16, 16, unsigned_magnitude, unchecked, void&gt;&gt; myNum16("0x000F"); </p> </blockquote> <blockquote> <p> char outBuf<a class="changeset" href="https://svn.boost.org/trac10/changeset/1000" title="(1) assignable added to BoundedTypes requirements. (2) slight ...">[1000]</a>; std::stringstream ss; ss &lt;&lt; setfill('0'); ss &lt;&lt; "7 bit : " &lt;&lt; std::setw(2) &lt;&lt; std::hex &lt;&lt; myNum07 &lt;&lt; endl; ss &lt;&lt; "8 bit : " &lt;&lt; std::setw(2) &lt;&lt; std::hex &lt;&lt; myNum08 &lt;&lt; endl; ss &lt;&lt; "9 bit : " &lt;&lt; std::setw(2) &lt;&lt; std::hex &lt;&lt; myNum09 &lt;&lt; endl; ss &lt;&lt; "16 bit: " &lt;&lt; std::setw(2) &lt;&lt; std::hex &lt;&lt; myNum16 &lt;&lt; endl; strncpy(outBuf, ss.str().c_str(), 999); printf("%s\n", outBuf); </p> </blockquote> <p> output is: </p> <hr /> <p> 7 bit : 0☼ 8 bit : 0☼ 9 bit : 0f 16 bit: 0f </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8745 Trac 1.4.3 John Maddock Mon, 01 Jul 2013 18:14:15 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/8745#comment:1 https://svn.boost.org/trac10/ticket/8745#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> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/84928" title="Correct output of small-integer types. Fixes #8745.">[84928]</a>) Correct output of small-integer types. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8745" title="#8745: Bugs: stream operator &lt;&lt; for number/cpp_int_backend with 8 bit or less ... (closed: fixed)">#8745</a>. </p> Ticket