output:Code:#include <iostream> #include <iomanip> using namespace std; int main() { int num; while (true) { cout << "N: "; cin >> num; if (! num) break; cout << hex << num << " " << dec << num << " " << oct << num << endl; } return 0; }
N: 12
c 12 14
N: -12
fffffff4 -12 37777777764
N:0
Question: Why negative numbers get strange values in hex and oct?
Actually I feel the hex value is natural, since that's how a negative number is internally. But why oct output is garbage?