formatting with showbase with hex for 0

C

Charles

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,173
Latest member
GeraldReund
Top