Category Archive

The following is a list of all entries from the Programming category.

Weird Hex Output

In C++, to output and integer in hex, I’d been taught to do this:

1
cout << hex << an_integer;

And if I want to show “0x” before the value, I need to do the following:

1
2
cout.setf(ios::showbase);
cout << hex << an_integer;

The above code works well for either positive or negative integers, but not the value ZERO. If I run [...]