How is C++ supposed to print negative values in base 8 or 16? I know I can try what my current compiler/library does (it prints the bit pattern, without a minus in front) but I want to know what is should do, preferrably with a reference.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From §22.2.2.2.2 (yes, really) of n1905, using
ios_base::hexis equivalent to thestdioformat specifier%xor%X.From §7.21.6.1 of n1570, the
%xspecifier interprets its argument as an unsigned integer.(Yes, I realize that those are wacky choices for standards documents. I’m sure you can find the text in your favorite copy if you look hard enough.)