Binary number system

Introduction to the Binary Number System

I recently introducedDecimal system, We are used as human beings.

As I said in that article, as humans, we usually have 10 fingers, and we can count up to 10 fingers, so this system is very popular in our history.

ThisBinary number systemFor humans, it is the second most important system because it led the revolution in electronics and computers.

In electronic products, we have 2 states: 0 or 1. There is 0 volts, or there are 5 volts (or 9, 12, whatever). Whether the door is open or closed.

Is one or the other.

The numbers in the binary number system are calledA small amount.

As a decimal number system, so is a binary number systemLocation.

We add up each number in the binary number system and multiply it by a power of 2, depending on their position, starting from position 0 on the right.

Given:

\ [2 ^ 0 \] is equal to 1


\ [2 ^ 1 \] is equal to 2


\ [2 ^ 2 \] equals 4


\ [2 ^ 3 \] is equal to 8, and so on.



We can use a series of bits to represent numbers:

1Can be expressed as \ [1 \ times2 ^ 0 \]



10Can be expressed as \ [1 \ times2 ^ 1 + 0 \ times2 ^ 0 \]



111It can be expressed as \ [1 \ times2 ^ 2 +1 \ times2 ^ 1 +1 \ times2 ^ 0 \]



You can remove or add leading zeros in the numbers, because they don’t mean anything in the upper left corner1:110It can be expressed as0110or00000110If needed. It has the same exact meaning, because as explained by the system above, we only need to multiply the power of 2 by zero.

Using binary numbers, we can represent any type of number in the decimal number system.

We need to have enough numbers to represent enough numbers. If we want to have 16 numbers, then we can count from 0 to 15, and we need 4 numbers (digits). Using 5 digits, we can calculate 32 numbers. 32 bits will give us4,294,967,296Possible numbers.

64 bit will give us9,223,372,036,854,775,807Possible numbers. It grows very fast.

This is a simple conversion table of the first 4 digits, we can generate the table using only 2 digits:

Decimal Binary number
0 00
1 01
2 10
3 11

This is a simple conversion table for the first 8 bits:

Decimal Binary number
0 000
1 001
2 010
3 011
4 100
5 101
6 110
7 111

If you notice, I repeated the above sequence and added1instead0In the series from 4 to 7.

This is a simple conversion table for the first 16 bits:

Decimal Binary number
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
10 1010
11 1011
12 1100
13 1101
14 1110
15 1111

Again, I repeated the order we used to get the first 8 numbers, setting 0 before the first set of numbers 0-7 and 1 before 8-15.

I will soon discuss how to perform operations such as summation and division with binary numbers, the hexadecimal number system, how to convert from binary to decimal, and to hexadecimal without having to look at tables like this, and vice versa.


More computer tutorials: