0x08 vs 8

What is the deference in 0x08 and 8?
There's no difference. 0x08 is in hexidecimal (with a base of 16).
0x <-- Notation of a HEX base number.
0 <-- Notation of a decimal base number.

So 0x8 is hex.
08 (or just 8) is decimal.

In case you're not familiar with those number systems.
When we count, we count from 1 to 10, and from there we increase our tenths by 1. because we increase it each 10 numbers, it's a 10 based system).

HEX (hexadecimal) however is a 15 based system. it counts:

1 2 3 4 5 6 7 8 9 A B C D E F 10. and then it continues to:
11 12 13 14 15 16 17 18 19 1A 1B 1C etc. etc.

As for 0x8 and 8. they hold the same value.
08 (or just 8) is decimal.

No, it's octal (base 8), but it will not compile because digits in octal numbers can't be as high as 8.
8 is a decimal number
@Peter87

I didn't mean 8 based. I just meant the number 8.
Last edited on
0*08 is a hexadecimal no: while
08 is a decimal number.









I Hope this is correct
@Arjun Padmanabhan

Yes it is.
@Hadar / Arjun Padmanabhan

No it isn't.

Peter87 is right: in C/C++ a number with a leading zero is interpreted as octal

We do not count from 1 to 10. It is from 0 to 9. 10 is already a combination.
Similar hex: 0x0 to 0xf
octal: 00 to 07
8->8 in decimal
0x8->8 in hexadecimal
08->ERROR!! ERROR!! 8 in octal-no such digit!
@coder777 Didn't take octal into consideration at all. I believe you're correct. as for the counting, I made a point and so tried to familiarize it as much as I could. it's okay that you mentioned it but you don't really have to read into it that much.
Topic archived. No new replies allowed.