0% found this document useful (0 votes)
38 views11 pages

LM - Unit-3 2

Uploaded by

raisinghdaksh2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views11 pages

LM - Unit-3 2

Uploaded by

raisinghdaksh2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

UNIT 3: NUMBER SYSTEM

3.1 Introduction of Decimal, Binary, Octal and Hexadecimal number Systems.


3.2 Conversion of Decimal to Binary and Binary to Decimal
3.3 Binary addition & subtraction
3.4 ASCII and ANSI character code

TYPES OF NUMBER SYSTEM


There are various types of number systems in mathematics. The four most common number system types are:
1. Decimal number system (Base- 10)
2. Binary number system (Base- 2)
3. Octal number system (Base-8)
4. Hexadecimal number system (Base- 16)

DECIMAL NUMBER SYSTEM (BASE 10 NUMBER SYSTEM)


The decimal number system has a base of 10 because it uses ten digits from 0 to 9. In the decimal number
system, the positions successive to the left of the decimal point represent units, tens, hundreds, thousands
and so on. This system is expressed in decimal numbers. Every position shows a particular power of the base
(10).
Example of Decimal Number System:
The decimal number 1457 consists of the digit 7 in the units position, 5 in the tens place, 4 in the hundreds
position, and 1 in the thousands place whose value can be written as:
(1×103) + (4×102) + (5×101) + (7×100)
(1×1000) + (4×100) + (5×10) + (7×1)
1000 + 400 + 50 + 7
1457

BINARY NUMBER SYSTEM (BASE 2 NUMBER SYSTEM)


The base 2 number system is also known as the Binary number system wherein, only two binary digits exist,
i.e., 0 and 1. Specifically, the usual base-2 is a radix of 2. The figures described under this system are known as
binary numbers which are the combination of 0 and 1. For example, 110101 is a binary number.

OCTAL NUMBER SYSTEM (BASE 8 NUMBER SYSTEM)


In the octal number system, the base is 8 and it uses numbers from 0 to 7 to represent numbers. Octal
numbers are commonly used in computer applications. Converting an octal number to decimal is the same as
decimal conversion and is explained below using an example.
Example: 215

HEXADECIMAL NUMBER SYSTEM (BASE 16 NUMBER SYSTEM)


In the hexadecimal system, numbers are written or represented with base 16. In the hex system, the numbers
are first represented just like in the decimal system, i.e. from 0 to 9. Then, the numbers are represented using
the alphabet from A to F. The below-given table shows the representation of numbers in the hexadecimal
number system.
Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F

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

DECIMAL TO BINARY (FRACTION NUMBER)


Given a fraction decimal number n and integer k, convert decimal number n into equivalent binary number
up-to k precision after decimal point.
Examples:
Input: n = 2.47, k = 5
Output: 10.01111

Input: n = 6.986 k = 8
Output: 110.11111100

Solution:-

A) Convert the integral part of decimal to binary equivalent


Divide the decimal number by 2 and store remainders in array.
Divide the quotient by 2.
Repeat step 2 until we get the quotient equal to zero.
Equivalent binary number would be reverse of all remainders of step 1.
B) Convert the fractional part of decimal to binary equivalent
Multiply the fractional decimal number by 2.
Integral part of resultant decimal number will be first digit of fraction binary number.
Repeat step 1 using only fractional part of decimal number and then step 2.
C) Combine both integral and fractional part of binary number.

Illustration :
Let's take an example for n = 4.47 k = 3

Step 1: Conversion of 4 to binary


1. 4/2 : Remainder = 0 : Quotient = 2
2. 2/2 : Remainder = 0 : Quotient = 1
3. 1/2 : Remainder = 1 : Quotient = 0

So equivalent binary of integral part of decimal is 100.

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

So equivalent binary of fractional part of decimal is .011

Step 3: Combined the result of step 1 and 2.

Final answer can be written as:


100 + .011 = 100.011

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

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.

Reading the remainders from bottom to top we get,


42310 = 1A716

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

Convert (110.101)2 = ( ? )10


Step 1: Conversion of 110 to decimal
=> 1102 = (1*22) + (1*21) + (0*20)
=> 1102 = 4 + 2 + 0
=> 1102 = 6
So equivalent decimal of binary integral is 6.

Step 2: Conversion of .101 to decimal


=> .101 = 1*2-1 + 0*2-2 + 1*2-3
=> 0.101 = (1*1/21) + (0*1/22) + (1*1/23)
=> 0.101 = 1*0.5 + 0*0.25 + 1*0.125
=> 0.101 = 0.5 + 0 + 0.125
=> 0.101 = 0.500 + 0.000 + 0.125
=> 0.101 = 0.625
So equivalent decimal of binary fractional is 0.625

Step 3: Add result of step 1 and 2.


=> 6 + 0.625 = 6.625

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

Let’s take an example to understand this.

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:

STEP 1: CONVERT (FF) 16 INTO BINARY


In order to convert the hexadecimal number into binary, we need to express every hexadecimal value using 4
binary bits.
Binary equivalent of f is (1111)2
= (ff)16
= (1111)(1111)
= (11111111)2
STEP 2 : CONVERT (11111111) 2 INTO OCTAL
In order to convert the binary number into octal, we need to group every 3 binary bits and calculate the
value[From left to right].
(11111111) 2 IN OCTAL
= (11111111)2
= (11)(111)(111)
= (377)8

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

OPERATION ON NUMBER SYSTEM

ADDITION:

RULES OF BINARY ADDITION


Binary addition is much easier than the decimal addition when you remember the following tricks or rules.
Using these rules, any binary number can be easily added. The four rules of binary addition are:
 0+0=0
 0+1=1
 1+0=1
 1 + 1 =10
HOW TO DO BINARY ADDITION?
Now, look at the example of the binary addition:101 + 101
Procedure for Binary Addition of Numbers:
101
(+) 101
 Step 1: First consider the 1’s column, and add the one’s column,( 1+1 ) and it gives the result 10 as per
the condition of binary addition.
8
 Step 2: Now, leave the 0 in the one’s column and carry the value 1 to the 10’s column.
1
101
(+) 101
————–
0
 Step 3: Now add 10’s place, 1+( 0 + 0 ) = 1. So, nothing carries to the 100’s place and leave the value 1
in the 10’s place
1
101
(+) 101
————-
10
 Step 4: Now add the 100’s place ( 1 + 1 ) = 10. Leave the value 0 in the 100’s place and carries 1 to the
1000’s place.
1
101
(+) 101
————-
1010
So, the resultant of the addition operation is 1010.
When you cross-check the binary value with the decimal value, the resultant value should be the same.
The binary value 101 is equal to the decimal value 5
So, 5 + 5 = 10
The decimal number 10 is equal to the binary number 1010.

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,

HOW TO DO BINARY SUBTRACTION?


Decimal or base-10 numbers can be expressed as binary numbers. Binary numbers are used in computers to
represent data since they understand only binary digits, 0 and 1. Let us understand how to subtract binary
numbers with the example shown below.
9
Case i) - Binary subtraction without borrowing
Subtract 1002 from 11112 .Here number 4 is represented in binary as 1002 and number 15 is represented
as 11112.
Step 1: Arrange the numbers as shown in the figure below.

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.

ASCII AND ANSI CHARACTER CODE

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.

Basis of ANSI ASCII


Comparison

American National Standards American Standard Code for


Full Form
Institute Information Interchange

Character 256 characters 128 characters


Represents

Bit Uses It uses 8-bit It uses 7-bit

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.

Complexity It is not simple to use. It is simple to use.

Standardized No Yes

11

You might also like