Modify

Ticket #8745 (closed Bugs: fixed)

Opened 10 months ago

Last modified 10 months ago

stream operator << for number/cpp_int_backend with 8 bit or less precision not working

Reported by: neal.p.smith@… Owned by: johnmaddock
Milestone: To Be Determined Component: multiprecision
Version: Boost 1.53.0 Severity: Problem
Keywords: multiprecision cpp_int_backend stream Cc:

Description

for 8 bit or less numbers << 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.

number<cpp_int_backend<7, 7, unsigned_magnitude, unchecked, void>> myNum07( "0xF"); number<cpp_int_backend<8, 8, unsigned_magnitude, unchecked, void>> myNum08( "0x0F"); number<cpp_int_backend<9, 9, unsigned_magnitude, unchecked, void>> myNum09( "0x0F"); number<cpp_int_backend<16, 16, unsigned_magnitude, unchecked, void>> myNum16("0x000F");

char outBuf[1000]; std::stringstream ss; ss << setfill('0'); ss << "7 bit : " << std::setw(2) << std::hex << myNum07 << endl; ss << "8 bit : " << std::setw(2) << std::hex << myNum08 << endl; ss << "9 bit : " << std::setw(2) << std::hex << myNum09 << endl; ss << "16 bit: " << std::setw(2) << std::hex << myNum16 << endl; strncpy(outBuf, ss.str().c_str(), 999); printf("%s\n", outBuf);

output is:


7 bit : 0☼ 8 bit : 0☼ 9 bit : 0f 16 bit: 0f

Attachments

Change History

comment:1 Changed 10 months ago by johnmaddock

  • Status changed from new to closed
  • Resolution set to fixed

(In [84928]) Correct output of small-integer types. Fixes #8745.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.