Computers work with Binary code and also store information in Binary format.
A computer system normally stores characters (letters, number, symbols, spaces, etc) using the ASCII code.
Each character (letters, number, symbols, spaces, etc) is represented and stored using 8-bits (1 byte) of information.
Check ASCII Character Set in your machine.
$ man ascii
Read the following post for more details about Binary Number System.
ASCII is abbreviated from American Standard Code for Information Interchange.
ASCII was introduced in 1963 by ANSI abbreviated from American National Standards Institute.
Basic ASCII Character Set (Total 128 characters)
The basic ASCII codes use 7-bits for each character, so it can only represent 128 distinct characters.
7 bits = 27 = 128 distinct values
Extended ASCII Character Set (Total 128 characters)
The Extended ASCII character set uses 8-bits (1 byte) binary code, which gives an additional 128 characters. The extra characters represent characters from foreign languages and special symbols such as Ö € or →
There are 256 characters in total.
8 bits = 1 byte = 1 Character
28 = 256 distinct values
8 bits (1 byte) can represent only one decimal value. That is, it represent only one character in ASCII table.
01100001 = a
01100010 = b
If it looks very long to you, check decimal values from the following ASCII table. We could write "a" and "b" characters like below as well.
97 = a
98 = b
But even we represent characters in different number systems like decimal, hexadecimal etc, eventually it should be converted to binary number. Because this is what computers understand 🙂
As you can see in the following table, characters are listed in Char column. There are 128 characters in ASCII table which are represented in different number systems like "Decimal", "Hexadecimal", "Binary" or "Octal". But, computers just understand Binary codes. Rest of the numbers is for human. Because, it is easy for us.
Let say we want to write "Hello" word in file or memory, we need to map each character to binary number. As we wrote above 1 Character = 8 bits (1 byte)
- H = 01001000
- e = 01100101
- l = 01101100
- l = 01101100
- o = 01101111
Hello = 01001000 01100101 01101100 01101100 01101111
There are 5 characters in "Hello" word, so it is 5 bytes (or 40 bits) in computers.
You can find a table of characters in the following image.
In the ASCII character set, each binary value between 0 and 127 is given a specific character.
A different table is below.