Everything is working on binary number system in computers, so it is valid in IP addresses as well.
Assume that IP address is 192.168.1.0 in dotted-decimal format is equal to 11000000.10101000.00000001.00000000 in dotted-binary format.
Assume that Subnet Mask is 255.255.255.0 in dotted-decimal format is equal to 11111111.11111111.11111111.00000000 in dotted-binary format. Subnet Mask is shown in /24 in slash notation(known as CIDR notation)
IP Address with Subnet Mask can be shown in CIDR notation 192.168.1.0/24
CIDR gives a concise way to represent both an IP network and its size using a combination of an IP address and a number after a slash.
Subnet Mask is 24 after slash in decimal representation. In order to find out 24, Subnet mask should be represented in binary number system like 11111111.11111111.11111111.00000000. So, just count how many 1 bit there are in Subnet Mask.
IP Address and Subnet Mask in Decimal format: IP Address: 192.168.1.0 Subnet Mask: 255.255.255.0
IP Address and Subnet Mask in CIDR format: 192.168.1.0/24
IP Address and Subnet Mask in Binary format: IP Address: 11000000.10101000.00000001.00000000 Subnet Mask: 11111111.11111111.11111111.00000000
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 ExtendedASCII 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 = 0100100001100101011011000110110001101111
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.