LM - Unit-3 2
LM - Unit-3 2
Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1
CONVERSION
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.
The remainders are to be read from bottom to top to obtain the binary equivalent.
4310 = 1010112
Input: n = 6.986 k = 8
Output: 110.11111100
Solution:-
Illustration :
Let's take an example for n = 4.47 k = 3
2
Step 2: Conversion of .47 to binary
1. 0.47 * 2 = 0.94, Integral part: 0
2. 0.94 * 2 = 1.88, Integral part: 1
3. 0.88 * 2 = 1.76, Integral part: 1
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.
Convert (473)10 = ( ? )8
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.
BINARY TO DECIMAL:
In this conversion, binary number to a decimal number, we use multiplication method, in such a way that, if a
number with base n has to be converted into a number with base 10, then each digit of the given number is
multiplied from MSB to LSB with reducing the power of the base. Let us understand this conversion with the
help of an example.
Example 1. Convert (1101)2 into a decimal number.
Solution: Given a binary number (1101)2.
Now, multiplying each digit from MSB to LSB with reducing the power of the base number 2.
1 × 23 + 1 × 22 + 0 × 21 + 1 × 20
=8+4+0+1
= 13
Therefore, (1101)2 = (13)10
3
BINARY TO DECIMAL (FRACTION NUMBER)
Examples:
Input: n = 110.101
Output: 6.625
Input: n = 101.1101
Output: 5.8125
We strongly recommend that you click here and practice it, before moving on to the solution.
Following are the steps of converting binary fractional to decimal.
A) Convert the integral part of binary to decimal equivalent
Multiply each digit separately from left side of radix point till the first digit by 20, 21, 22,… respectively.
Add all the result coming from step 1.
Equivalent integral decimal number would be the result obtained in step 2.
B) Convert the fractional part of binary to decimal equivalent
Divide each digit from right side of radix point till the end by 21, 22, 23, … respectively.
Add all the result coming from step 1.
Equivalent fractional decimal number would be the result obtained in step 2.
C) Add both integral and fractional part of decimal number.
Illustration
Let's take an example for n = 110.101
BINARY TO OCTAL
To convert a binary number to octal number, these steps are followed −
Starting from the least significant bit, make groups of three bits.
If there are one or two bits less in making the groups, 0s can be added after the most significant bit
Convert each group into its equivalent octal number
Let’s take an example to understand this.
4
101100101012 = 26258
To convert an octal number to binary, each octal digit is converted to its 3-bit binary equivalent according to
this table.
Octal Digit 0 1 2 3 4 5 6 7
Binary Equivalent 000 001 010 011 100 101 110 111
546738 = 1011001101110112
BINARY TO HEXADECIMAL
To convert a binary number to hexadecimal number, these steps are followed −
Starting from the least significant bit, make groups of four bits.
If there are one or two bits less in making the groups, 0s can be added after the most significant bit.
Convert each group into its equivalent octal number.
Note:
Octal Digit 0 1 2 3 4 5 6 7
Binary 0000 0001 0010 0011 0100 0101 0110 0111
Equivalent
Octal Digit 8 9 A(10) B(11) C(12) D(13) E(14) F(15)
Binary 1000 1001 1010 1011 1100 1101 1110 1111
Equivalent
101101101012 = DB516
5
OCTAL TO DECIMAL:
To convert octal to decimal, we multiply the digits of octal number with decreasing power of the base number
8, starting from MSB to LSB and then add them all together.
Example 2: Convert 228 to Decimal number.
Solution: Given, 228
2 x 81 + 2 x 80
= 16 + 2
= 18
Therefore, 228 = 1810
OCTAL TO BINARY
To convert octal to binary number, we can simply use the table. Just like having a table for hexadecimal and its
equivalent binary, in the same way, we have a table for octal and its equivalent binary number.
Octal Number Binary
0 000
1 001
2 010
3 011
4 100
5 101
6 110
7 111
Example: Convert (214)8 into a binary number.
Solution: From the table, we know,
2 → 010
1 → 001
4 → 100
Therefore,(214)8 = (010001100)2
OCTAL TO HEXADECIMAL
octal digit to 3 binary digits, with this table:
Octal Binary
0 000
1 001
2 010
3 011
4 100
5 101
6 110
6
7 111
Then convert every 4 binary digits from bit0 to 1 hex digit, with this table:
Binary Hex
0000 0
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
1000 8
1001 9
1010 A
1011 B
1100 C
1101 D
1110 E
1111 F
EXAMPLE
Convert octal 1548 to hex:
Convert every octal digit to 3 binary digits:
1548 = 001 101 100 = 0011011002
Then convert every 4 binary digits to 1 hex digit:
0011011002 = 0110 1100 = 6C16
HEXADECIMAL TO BINARY
Convert every hex digit (start lowest digit) to 4 binary digits, with this table:
Hex Binary
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
A 1010
B 1011
C 1100
D 1101
7
E 1110
F 1111
EXAMPLE
Convert hex 6C16 to binary:
6C16 = 6 C = 110 1100 = 11011002
HEXADECIMAL TO OCTAL:
HEXADECIMAL TO DECIMAL:
Example 3: Convert 12116 to decimal number.
Solution: 1 x 162 + 2 x 161 + 1 x 160
= 16 x 16 + 2 x 16 + 1 x 1
= 289
Therefore, 12116 = 28910
ADDITION:
BINARY SUBTRACTION
Binary subtraction is the process of subtracting binary numbers. Binary numbers include only 0 and 1. The
process of binary subtraction is the same as the arithmetic operation of subtraction that we do with numbers.
Since only 0 and 1 are involved here, we may sometimes need to subtract 0 from 1. In such cases, we use the
concept of borrowing as we do in an arithmetic subtraction. A binary number is expressed with a base-2. For
example, a binary number is written as 10121012
RULES OF BINARY SUBTRACTION
There are some rules in which binary numbers are subtracted. They are,
Step 2: Follow the binary subtraction rules to subtract the numbers. In this subtraction, we do not encounter
the subtraction of 1 from 0. Hence, the difference is 10112.
Step 3: The decimal equivalent of 10112 is 11. Hence the difference is correct.
Case ii) Binary subtraction with borrowing
Subtract 1012 from 10012. Here number 5 is represented in binary as 1012 and number 9 is represented
as 10012.
Step 1: Arrange the numbers as shown below.
Step 2: Follow the binary subtraction rules to subtract the numbers. In this subtraction, first, let us subtract
the numbers starting from the right and move to the next higher order digit. The first step is to subtract (1-1).
This is equal to 0. Similarly, we move on to the next higher order digit and subtract (0 - 0), which is 0. In the
next step, we have to subtract (0 - 1), so we borrow a 1 from the next higher order digit. Therefore, the result
of subtracting (0 - 1) is 1.
Step 3: Therefore the difference of 10012 and 1012 is 1002. To verify this, let us find the decimal equivalent
of 1002, which is 4, Therefore, 9 - 5 = 4.
WHAT IS ANSI?
The American National Standards Institute (ANSI) codes are standardized numeric or alphabetic identifiers
that are issued by the American National Standards Institute to enable uniform identification of geographic
entities across all federal government departments. These codes can be found on ANSI documents. It is a
generic term for the default code page of a given operating system, such as Windows
WHAT IS ASCII?
10
ASCII stands for the "American Standard Code for Information Interchange".
It was designed in the early 60's, as a standard character set for computers and electronic devices.
ASCII is a 7-bit character set containing 128 characters.
It contains the numbers from 0-9, the upper and lower case English letters from A to Z, and some special
characters.
Life Span It has shorter life span It has longer life span
Within the context of the Every single system uses ASCII code
Consistency
system, these are not the same. points that are precisely the same.
Standardized No Yes
11