Thursday, 15 February 2024

Solved Example on Number System Set-II (Binary to Decimal, Octal, Hexadecial)

1. How to convert binary to decimal ?

1. Find the position of every binary digit. We should count the position from the right direction of the number. And the position count starts from 0.

Example

0001 - position of 1 = 0, 0 = 1, 0 = 2, 0 = 3.

2. Multiply every digit with 2 to the power of their corresponding position. (2 position)

3. Finally, calculate the sum of all the multiples.

Example: Convert (1111)2 to decimal

= 1 x 2 3 + 1 x 2 2 + 1 x 2 1 + 1 x 2 0

= 8 + 4 + 2 + 1

= (15)10

Example: Convert (1001)2 to decimal

 = 1 x 2 3 + 0 x 2 2 + 0 x 2 1 + 1 x 2 0

 

= 8 + 0 + 0 + 1

= (9)10

2. How to convert binary to octal ?

Group every 3 binary bits from right to left and construct the octal number system.

Example: (101010101)2 to octal

= (101010101)2

= (101)(010)(101)

= (525)8

Example: (11111111)2 to octal

= (11111111)2

= (11)(111)(111)

= (377)8

3. How to convert binary to hexadecimal ?

Group every 4 binary bits from right to left and construct the hexadecimal number system.

Example: (101010101)2 to hexadecimal

= (101010101)2

= (1)(0101)(0101)

= (155)16

Example: (11111111)2 to hexadecimal

= (11111111)2

= (1111)(1111)

= (15)(15)

= (ff)16

Converting Decimal Fraction to Binary, Octal, Hexadecimal

A fractional number is a number less than 1. It may be .5, .00453, .564, etc. We use the multiplication operation to convert decimal fraction to any other base.
To convert a decimal fraction to—
• binary - multiply by 2
• octal - multiply by 8
• hexadecimal - multiply by 16

Steps for conversion of a decimal fraction to any other base are—

1. Multiply the fractional number with the to Base, to get a resulting number.
2. The resulting number has two parts, non-fractional part and fractional part.
3. Record the non-fractional part of the resulting number.
4. Repeat the above steps at least four times.
5. Write the digits in the non-fractional part starting from upwards to downwards.

Example-1: Convert 0.2345 from Base 10 to Base 2

Convering decimal fraction to Binary

The binary equivalent of (0.2345)10 is (0.001111)2

Example-2: Convert 0.865 from Base 10 to Base 2,8 and 16

Decimal fraction to Binary Conversion

Solved Example on Number System Set-I (Decima to Binary, Octal, Hexadecimal conversion)

As you know decimal, binary, octal and hexadecimal number systems are positional value number systems. To convert binary, octal and hexadecimal to decimal number, we just need to add the product of each digit with its positional value. Here we are going to learn other conversion among these number systems.

Decimal to Binary

Decimal numbers can be converted to binary by repeated division of the number by 2 while recording the remainder. Let’s take an example to see how this happens.

Decimal To Binary

The remainders are to be read from bottom to top to obtain the binary equivalent.

4310 = 1010112

Decimal to Octal

Decimal numbers can be converted to octal by repeated division of the number by 8 while recording the remainder. Let’s take an example to see how this happens.

Decimal To Octal

Reading the remainders from bottom to top,

47310 = 7318

Decimal to Hexadecimal

Decimal numbers can be converted to octal by repeated division of the number by 16 while recording the remainder. Let’s take an example to see how this happens.

Decimal To Hexadecimal

Reading the remainders from bottom to top we get,

 42310 = 1A716

 

Here you find step by step process of fractional number conversion to any other number systems. It is very easy to do with some specified steps those are
  • We have to multiply the fractional number by base to which number system we want to convert, until the all fractional part is remove/zero.
  • Every time we have to take the integer value (before point) after every multiplication, until the all fractional part is remove/zero.
  • Then the column of this integer value is read in forward order. That means we have to count those reminder from top to button.
Now take an example to understand the process easily.

Let we have to convert 0.25 decimal numbers to binary number system.

As we discuss above that we have to multiply the fractional number by base to which number system we want to convert. So here we convert the fractional number in binary so we have to multiply by 2.

Now see that process

0.25 x 2 = 0.50   0

0.50 x 2 =1.00     1

See in time of second multiplication the fractional part is remove/zero. So we stop our multiplication and take the column of integer value written in right hand side from top to button.

So equivalent of .2510 is 0.012.

Now if we convert this same number 0.2510 in octal number then we have to multiply with 8.Because the base of octal number is 8.

0.25 x 8 = 2.00        2

So equivalent of .2510 is 0.28.

Now if we convert this same number 0.2510 in Hexadecimal number then we have to multiply with 16.Because the base of octal number is 16.

0.25 x 16 = 4.00 4

So equivalent of .2510 is 0.416.

weighted and unweighted codes

In the coding, when numbers, letters or words are represented by a specific group of symbols, it is said that the number, letter or word is being encoded. The group of symbols is called as a code. The digital data is represented, stored and transmitted as group of binary bits. This group is also called as binary code. The binary code is represented by the number as well as alphanumeric letter.

Advantages of Binary Code

Following is the list of advantages that binary code offers.

  • Binary codes are suitable for the computer applications.

  • Binary codes are suitable for the digital communications.

  • Binary codes make the analysis and designing of digital circuits if we use the binary codes.

  • Since only 0 & 1 are being used, implementation becomes easy.

Classification of binary codes

The codes are broadly categorized into following four categories.

  • Weighted Codes
  • Non-Weighted Codes
  • Binary Coded Decimal Code
  • Alphanumeric Codes
  • Error Detecting Codes
  • Error Correcting Codes

Weighted Codes

Weighted binary codes are those binary codes which obey the positional weight principle. Each position of the number represents a specific weight. Several systems of the codes are used to express the decimal digits 0 through 9. In these codes each decimal digit is represented by a group of four bits.

Weighted Code

Non-Weighted Codes

In this type of binary codes, the positional weights are not assigned. The examples of non-weighted codes are Excess-3 code and Gray code.

Excess-3 code

The Excess-3 code is also called as XS-3 code. It is non-weighted code used to express decimal numbers. The Excess-3 code words are derived from the 8421 BCD code words adding (0011)2 or (3)10 to each code word in 8421. The excess-3 codes are obtained as follows −

Excess-3 code

Example

BCD to Excess-3 code

Gray Code

It is the non-weighted code and it is not arithmetic codes. That means there are no specific weights assigned to the bit position. It has a very special feature that, only one bit will change each time the decimal number is incremented as shown in fig. As only one bit changes at a time, the gray code is called as a unit distance code. The gray code is a cyclic code. Gray code cannot be used for arithmetic operation.

Gray code

Application of Gray code

  • Gray code is popularly used in the shaft position encoders.

  • A shaft position encoder produces a code word which represents the angular position of the shaft.

Binary Coded Decimal (BCD) code

In this code each decimal digit is represented by a 4-bit binary number. BCD is a way to express each of the decimal digits with a binary code. In the BCD, with four bits we can represent sixteen numbers (0000 to 1111). But in BCD code only first ten of these are used (0000 to 1001). The remaining six code combinations i.e. 1010 to 1111 are invalid in BCD.

BCD code

Advantages of BCD Codes

  • It is very similar to decimal system.
  • We need to remember binary equivalent of decimal numbers 0 to 9 only.

Disadvantages of BCD Codes

  • The addition and subtraction of BCD have different rules.

  • The BCD arithmetic is little more complicated.

  • BCD needs more number of bits than binary to represent the decimal number. So BCD is less efficient than binary.

Alphanumeric codes

A binary digit or bit can represent only two symbols as it has only two states '0' or '1'. But this is not enough for communication between two computers because there we need many more symbols for communication. These symbols are required to represent 26 alphabets with capital and small letters, numbers from 0 to 9, punctuation marks and other symbols.

The alphanumeric codes are the codes that represent numbers and alphabetic characters. Mostly such codes also represent other characters such as symbol and various instructions necessary for conveying information. An alphanumeric code should at least represent 10 digits and 26 letters of alphabet i.e. total 36 items. The following three alphanumeric codes are very commonly used for the data representation.

  • American Standard Code for Information Interchange (ASCII).
  • Extended Binary Coded Decimal Interchange Code (EBCDIC).
  • Five bit Baudot Code.

ASCII code is a 7-bit code whereas EBCDIC is an 8-bit code. ASCII code is more commonly used worldwide while EBCDIC is used primarily in large IBM computers.

Error Codes

There are binary code techniques available to detect and correct data during data transmission.

Error Code Description

Error Detection and Correction

Error detection and correction code techniques

Latest Notifications

More

Results

More

Timetables

More

Latest Schlorships

More

Materials

More

Previous Question Papers

More

All syllabus Posts

More

AI Fundamentals Tutorial

More

Data Science and R Tutorial

More
Top