DEV Community

Lev Titanyan
Lev Titanyan

Posted on

Binary Numbers

Binary numbers consist of only 1-s and 0-s.
Binary numbers are used in mathematics and technologies.
Programming is done using a binary number system since the computer only understands the language of the two digits 0 and 1.
We can do mathematical operations with binaries, such as addition, multiplication, subtraction and division.

Addition.
Addition is the same as with the ordinary numbers. The only difference is that we should follow the following rules.
Addition rules:

  1. 0+0=0
  2. 0+1=1
  3. 1+0=1
  4. 1+1=10

For example: 11111+1101=101100

Multiplication.
Multiplication is also the same as the normal multiplication. The rules of multiplication:

  1. 0*0=0
  2. 0*1=0
  3. 1*0=0
  4. 1*1=1

For instance: 11111+1101=110010011

Subtraction.
Subtraction is also the way normal numbers are subtracted.
The rules of subtraction:

  1. 0-0=0
  2. 0-1=1(borrow:1)
  3. 1-0=1
  4. 1-1=0

For example: 101000-11110=1010

We can also convert binaries into decimals. In order to convert a binary number to a decimal number, we must multiply each digit of the binary number by powers of 2(powers start at 0) and then add the results to get the decimal number.

For example: 11011-> decimal number
1*2^0+1*2^1+0*2^2+1*2^3+1*2^4 = 1+2+0+8+16=27
Hence, 11011 in decimal is 27.

Top comments (0)