By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,159 Members | 938 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,159 IT Pros & Developers. It's quick & easy.

formatting with showbase with hex for 0

P: n/a
Is it possible to get a hex formatted value of 0 to output with the
base as 0x0?

#include <iostream>
#include <iomanip>
using namespace std;

int main ()
{
cout << "dec 0 = " << 0 << endl;
cout << "dec 1 = " << 1 << endl;
cout << "hex 0x0 = " << hex << showbase << 0 << endl;
cout << "hex 0x1 = " << hex << showbase << 1 << endl;

return 0;
}

Thank you for responding to my painfully simple question.
Charles

Here is the same output for vc++ and g++ :
dec 0 = 0
dec 1 = 1
hex 0x0 = 0
hex 0x1 = 0x1
Jul 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.