简体   繁体   中英

What is the difference between 65 and the letter A in binary?

65 和二进制字母 A 之间有什么区别,因为它们都表示相同的位级别信息?

Basically, a computer only understand numbers, and not every numbers: it only understand binary represented numbers, ie. which can be represented using only two different states (for example, 1 and 2, 0V and 5V, open and close, true or false, etc. ).

Unfortunately, we poor humans doesn't really like reading zeros and ones... So, we have created some codes , to use number like if they were characters: one of them is called ASCII ( American Standard Code for Information Interchange ), but there is also some others, such as Unicode. The principle is simple: all the program have to do is manipulating numbers, what any CPU does very well, but, when it comes to displaying these data, the display represent them as real characters, such as 'A', '4', '@', or even a space or a newline.

Now, as soon as you are using ASCII, the number 65 will represent the letter 'A'. All is a question of representation: for example, the binary number 0bOOOO1111, the hexadecimal one 0x0F, the octal one 017 and the decimal number 15 all represent the same number. It's the same for letter 'A': think of ASCII as a base , but instead of using the base 2 (binary), 8(octal), 10(decimal) or 16(hexadecimal), to display numbers, it's used in a complete different manner.

To answer your question: ASCII 'A' is hexadecimal 0x41 is decimal 65 is octal 0101 is binary 0b01000001.

Every character is represented by a number. The mapping between numbers and characters is called encoding. Many encodings use for the letter A the number 65. Since in memory there are no special cells for characters or numbers, they are represented the same way, but the interpretation in any program could be very different.

First of all, the difference can be in size of the memory (8bits, 16bits or 32bits). This question: bytes of a string in java

Secondly, to store letter 'A' you can have different encodings and different interpretation of memory. The ASCII character of 'A' in C can occupy exact one byte (7bits + an unused sign bit) and it has exact same binary value as 65 in char integer. But the bitwise interpretation of numbers and characters are not always the same. Just consider that you can store signed values in 8bits. This question: what is an unsigned char

I may be misunderstanding the question and if so I apologise for getting it wrong

But if I'm right I believe your asking what's the difference between a char and int in binary representation of the value 65 which is the ascii decimal value for the letter A (in capital form)

First off we need to appreciate data types which reserve blocks of memory in the ram modules

An interget is usually 16 bits or more if a float or long (in c# this declaration is made by stating uint16, int16, or int32, uint32 so on, so forth)

A character is an 8 bit memory block

Therefore the binary would appear as follows

A byte (8 bits) - char Decimal: 128, 64, 32, 16, 8, 4, 2, 1 Binary: 01000001

2 bytes (16 bit) - int16 Binary; 0000000001000001

Its all down to the size of the memory block reserved based on the data type in the variable declaration

I'd of done the decimal calculations for the 2 bit but I'm on the bus at the moment

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