Numbers starting with a 0
are in octal. Octal digits between 0 and 7. Counting in octal goes:
0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 17, 20, ...
Numbers starting with a 0x
or 0X
are in hexadecimal (hex). Hex uses digits and alpha values. Counting in Hex goes:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10, ...
So how is 01168 == 0x4E16?
The C compiler will see the 0
in 0116
and know to interrupt the number as octal. The compiler can check different number systems against each other where as we, mostly humans, need to convert them to something we can understand better.
Converting Octal to Decimal can be done as the Σ (for i=0 to n) of the function: aix8i. In your example:
1x82 = 64
1x81 = 8
6x80 = 6
64+8+6 = 7810
Converting Hex to Decimal can be done with nearly the same formula but you need to convert each letter to the decimal equivalent for the ai portion of: aix16i.
4x161 = 64
14x160 = 14 //E16 == 1410
64+14 = 7810
Clearly 78==78, the compilter just doesn't need to do the conversion first to see that.