简体   繁体   中英

Whats the difference between ASCII code and binary in representation

Say 5 as a value. In ASCII code its 00110101 and in binary it is 00000101. How can we explain this in a right way.

As i know the binary is equivalent to the equation 2^2 + 2^0 = 5. How should i explain the ASCII part?

5 is a value, but this 5 you are asking about is not a value in the ASCII table but a character or in other words an entity, so it is not 5, but "5". And it just happens that "5" is at the position 53.

You are mixing up a value itself and its index's value, but you are able to do it because we (humans) understand "5" as a number and know that it is a measure of quantity. If you run this logic on "A" it will fail, as "A" is not a number and you won't be able to represent it as sum of the power of 2s.

But in the ASCII table there is "A", it has an index and that index has a value, but they are not related at all.

Remember, we have two things. 1. Value(integer) 2. Character

Now, if you say '5', it is a character. and 5 is the integral value.

The characters are always stored in the form of ASCII/UNICODE or something like that.

Now, '5' has the ASCII 53 which in BINARY makes 00110101

And 5 as the number makes 00000101.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM