Hex Format a little confused


Is my understanding correct?

Ascii 'a' = 61 (Hex)
Ascii '0' = 30 (Hex)

So this is how we convert characters to hex.


Integer 0 = 0 (Hex), because it's not a character but an integer.

I need help because I want to be sure I understand this correctly.
So this is how we convert characters to hex.
You look them up in the characterset.
http://www.asciitable.com/
http://www.lookuptables.com/ebcdic_scancodes.php
Last edited on
Thank you but I am a little bit confused, as for:

Is hexa and hexadecimal the same thing?
yes
So the difference is when we convert ascii do hexa, or a number to hexadecial
ascii do hexa, or a number to hexadecial
There is no difference. Chars are numbers. What makes them appear as characters is special overloads for them and thing called character table which defines mapping from character value to actual symbol on screen.

http://ideone.com/7L4iTh
Thank you all for your answers.
Everything in a computer is represented by numbers in binary. Decimal, octal, hexadecimal, etc... are just different ways that we humans can express numbers, and any given binary number can freely be expressed in any of those bases we choose.

Characters can not be intrinsically represented by numbers, so people came up with ASCII, EBCDIC, Unicode, and other character sets to represent them in computers.

In memory a binary sequence of 01100001 could represent many things, what it actually means is entirely dependent upon how our programs interpret it.

As a number, that sequence could be read as decimal 97, hex 61, octal 141, or any other numeric base you wish to use. If you read that sequence as an ASCII character it represents 'a'.

Apologies if this sounds too pedantic.
In C++ char is integral type. That means it only differs from int in size. It can be passed to functions expecting int, short, long or other integral types. You can perform math operations on them: 'a' * '0' % '!' is a valid expression, because characters are integral values. It is not a separate entity as, say, pointer types (though they can be explicitely casted to and from integral values, they are not integral themself)
Topic archived. No new replies allowed.