+ 1

how cout<<"0x7b = "<<0x7b<<endl; produces output: 0x7b = 123

also cout<<"0x123 = " << 0x123 << endl; output: 0x123 = 291 Now I'm learning number system such as binary, unary, hexadecimal. I read forums. But I can't understand this. Please help me!

24th Jun 2018, 5:40 PM
Lucky
Lucky - avatar
3 Antworten
+ 1
123 in hex: 3*16^0 + 2*16 + 16^2 = 3 + 32 + 256 = 291 in decimal
24th Jun 2018, 6:20 PM
hinanawi
hinanawi - avatar
0
0x7b is hexadecimal, and its decimal form is 123, not 291.
24th Jun 2018, 5:45 PM
LunarCoffee
LunarCoffee - avatar
0
it's all still the same statement for the output.
28th Jun 2018, 12:14 AM
Plop This
Plop This - avatar