 # Number System for digital electronics

Number system is technique to write or represent the numbers. Most commonly used system is decimal number system. But in the electronics field there are some more number systems comes to know. Which are –

• Binary number system
• Octal number system

Now, I am going to explain about all of them one by one.

## Decimal number system

Now let’s first know about most commonly used number system which is decimal number system. In this number system the base is 10 and has 10 digits which are 0,1,2,3,4,5,6,7,8 and 9. Decimal system has a positional value for each digits of a number that is why it is called positional valued number system. let understand it by an example.

Suppose we have 123, value of 1 is hundreds that is 1×100. Value of 2 is tens that is 2×10=20 and so on. So we have this conclusion-

We can write the weightage for digits as following.

Through this table you can understand why the base is 10 of decimal number system.

## Binary number system

In binary number system the base is 2 and has 2 digits 0 and 1. This number system is used in electronics devices and digital communication. In which these number is represented by voltage levels. There are two voltage levels ON and OFF or HIGH and LOW. 1 represents ON or HIGH condition and 0 represents OFF or LOW condition. Each digits of binary number is also called Bit.

The base of binary numbers is 2, so the positional values of each binary digits is following.

Here is an example of a binary number is 111001 etc. In this number the rightmost digit is called least significant bit (LSB) and leftmost digit is called most significant bit (MSB).

11012 = 1×23 + 1×22 + 0x21 + 1×20

= 8 + 4 + 0 + 1    =  1310

As I said earlier binary digits is called bit and you might know that computer memory is measured in the terms of how many bits it stores. Here is some computer memory capacity conversions

.

1 byte = 8 bit

1 kilobyte (KB) = 1024 byte

1 megabyte (MB) = 1024 KB

1 gigabyte (GB) = 1024 MB

1 terabyte (TB) = 1024 GB

Octal number system

As it name suggests the base of these numbers is 8, and have 8 digits 0, 1,2,3,4,5,6,7. The positional value is shown below.

1238 = 1×82 +2×81 +3×80

= 64 + 8 + 3

= 7510

Hexadecimal number system has 16 symbol included 0-9 numbers and A-F alphabets. Where A is equal to 10, B is equal to 11 and so on. Base of these numbers is 16, so the positional values of its digits are given below.

The 16 digits of hexadecimal numbers are described below.

(0)10 = (0)16

(1)10 = (1)16

(2)10 = (2)16

(3)10 = (3)16

(4)10 = (4)16

(5)10 = (5)16

(6)10 = (6)16

(7)10 = (7)16

(8)10 = (8)16

(9)10 = (9)16

(10)10 = (A)16

(11)10 = (B)16

(12)10 = (C)16

(13)10 = (D)16

(14)10 = (E)16

(15)10 = (F)16

Let’s see an example

Let’s say we have 16F216 = 1×163 + 6×162 + 15×161 + 2×160

= 4,096 + 1,536 + 240 + 2  =  5,874

## Number system conversion

### Decimal to binary conversion

In order to convert the decimal to binary, number is divided by 2 continuously till the number is not divisible by 2 or last remainder is 1. Each remainder in reverse order is our binary number equivalent to that decimal number. The LSB of that binary number is the first remainder and MSB is the last remainder during division process. For an example

So, the binary number for 256 is 100000000. Here MSB is 1 that is last division value and LSB is 0 that is first remainder.

### Decimal to octal conversion

Process for convert decimal number to octal number is same as binary. For convert decimal to octal number is divided by 8 and the whole process is same as binary.

So, the octal number for 250 is 372.

For convert any decimal to hexadecimal number decimal number is divided by 16 and whole process is same as previous two.

The first remainder is 14 which is E in hexadecimal and second remainder is 15 which is F in hexadecimal. So, the hexadecimal number for 254 is FE.

### Binary to octal and octal to binary conversion

To convert binary to octal number make pairs of three digits of that binary number and convert all the pairs into the decimal number and that is your octal number.

Say we have a binary number 110011. Now make the group of that number in pairs of three digits. The first pair is 110 that is 6 in decimal and second pair is 011 that is 3 in decimal. So, the octal number is 63 of binary number 110011.

Reverse process gives binary number from an octal number.

To convert binary to hexadecimal number we need to make the group of pairs of four digits from a given binary number. Then convert them into hexadecimal numbers.

And same here, reverse process will give us hex to binary number.

### Octal to hex and hex to octal conversion

In this conversion two step is used which now you know. For convert octal to hexadecimal first convert octal number into the binary number and then convert that binary number into hexadecimal.

For convert hexadecimal number to octal number first convert hexadecimal number into the binary and convert that binary number into octal.

## Arithmetic operations on binary numbers

Say we have 101101 and 110011 two numbers and we have to add them. You can understand it by seeing the example below.

At the top of both number, carry is shown. After adding 1 and 1 we have to 10(2 in decimal). From which 0 is written in the sum and 1 is added as carry in the next bit addition.

### Subtraction of binary numbers

Now, we have same numbers and we have to subtract them this time.

First we have to subtract 1 from 1 and that is 0, then 0 from 1 i.e. 1, then we have to subtract 1 from 0 and this is not possible until we take 2 (10) as borrow from next bit. But next bit is also 0 so we have see further next until that bit is 1. 4th digit has taken 2(10) borrow from 5th digit and given it to 3rd digit as borrow and now 3rd digit is 10 (2), 4th digit is 1, and fifth digit is 0. Now we can subtract further.

Note: – for binary multiplication or division it is easy to first convert the number in decimal system.

## Arithmetic operation on octal numbers

Now we will add two octal numbers using the table given above.

First we have to add 6 and 4. If you see in the table then addition of 6 and 4 is 12. So, we have written 2 in the sum and 1 is carry for next digit addition.

### Subtraction of two octal numbers

Now see how to subtract two octal numbers.

In this subtraction first we have to subtract 1 from 2 i.e. 1, then 6 from 5, so we have to take borrow from next digit that is 4 (we cannot take borrow till digit is 0 and we have check further next digit). It will give us 8 as borrow. we will add this 8 to 5 and subtract 6 form it.

## Arithmetic operations on hexadecimal numbers

There is a table given below. By the help of this table, try to understand the addition process of two or more hexadecimal numbers.

In order to subtract 3F6 from 4E9, we have to first subtract 6 from 9 i.e. 3, then we have subtract F (15) from E (14), so we have to take 16 as borrow from next digit that is 4 and it will become 3. Now we will add that 16 to E and subtract F from the addition. 16 + E (14) will be 30 – F (15) will be 15 and that is F in hexadecimal.

## Representing negative numbers in binary

As we know there are only two digits are allowed in binary numbers. We will see that how we can represent negative numbers in binary system. There are two methods of representing negative numbers in binary.

### 1.     1’s complement

In this method all digits of binary number is inverted.

For example – 1’s complement of 1101001 is 0010110.

### 2.     2’s complement

In this method 1 is added in 1’s complement of a binary number.

For example – 2’s of 1001011 is 0110100+1 = 110101

In 2’s complement MSB represents that the number is negative or not. If MSB is zero then number is positive else it is negative.