Module 1 - Number Systems

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 60

Syllabus

• Binary and hexadecimal number systems;


Methods of base conversions; Binary and
hexadecimal arithmetic; Representation of
signed numbers; Fixed and floating point
numbers
• Binary coded decimal codes; Gray codes; Excess
3 code. Alphanumeric codes: ASCII. Error
detection and correction codes - parity check
codes and Hamming code;
• Basics of verilog -- basic language elements:
identifiers, data objects, scalar data types,
operators.
Module 1

Part 1
Contents
• Number Systems
– Decimal
– Binary
– Octal
– Hexadecimal
• Base conversion
Number system
• Number system: Representing the information
in the digital system.
• Eg: Computer – using binary number system
(0,1)
Decimal Number System
• The decimal numbers are used in our day to
day life.
• Uses ten digits 0,1,2,3,4,5,6,7,8 & 9
• Base-10 system, this system has a base of 10.
• The radix or base is the number of unique
digits including zero to represent numbers in a
positional weighted system.
• It is a Positional weighted system
• Each digit position has an associated weight
• Eg:
• In decimal number 74 (has 2 digits)
– digit 4 has a weight of 1 in this position &
– digit 7 has a weight of 10 in this position
• This can be expressed in the bases or radices of
the system (as powers of 10).
• So 74 can be represented as
7 X 10 + 4 X 1
=7 x 101 + 4 x 100
= 70 + 4 = 74
• Decimal number 6534 can be represented as
(6×1000) + (5×100) + (3×10) + (4×1)
= (6×103) + (5×102) + (3×101) + (4×100)
= 6000 + 500 + 30 + 4 = 6534
Decimal Number System
• The leftmost digit which has the greatest
positional weight is called the Most Significant Digit
(MSD) & its rightmost digit which has the least
positional weight is called the Least Significant Digit
(LSD)
• For eg: 6534
– 6 is MSD
– 4 is LSD
• Eg: Decimal number , 9256.26 (whole-
number part & fractional part separated by
a decimal point)
• The weights for whole numbers are positive
powers of 10, that increases from right to
left beginning with 100
• The weights for fractional numbers are
negative powers of 10 that decreases from
left to right beginning with 10-1

• ----103 102 101 100 . 10-1 10-2 10-3----


• 9256.26 expressed as
• (9x103 ) + (2x102) + (5x101) + (6x100) +
(2x10-1) + (6x10-2)

• The value of a decimal number is the sum of


products of the digits of that number with
their respective weights
Binary number system
• Uses only 2 digits 0 & 1 – binary digit is called a bit.
• A positional weighted system, weight of each bit
position is expressed as powers of 2
• Base–2 system : Base or radix is 2
• Take a binary number, binary point separates integer
part and fractional part.
---- 23 22 21 20 . 2-1 2-2 2-3 ----
• LSB & MSB – Least Significant bit & Most significant bit
Binary number system…
• Eg: (1010)2, (110110)2
• In binary number system, a group of four bits is
known as nibble and a group of 8 bits is known
as a byte
• The binary number system is used in digital
computers & are represented as ON/OFF, 0/1
or TRUE/FALSE
Octal Number System
• Consists of 8 digits, 0,1,2,3,4,5,6,7
• Has a base of 8
• A positional weighted system, weight of each
position is expressed as powers of 8
• Use the subscript 8 to indicate an octal no.
• Eg : (273)8, (5644)8
• Groups of three (binary) digits can be used to
represent each octal digit.

Octal Number Binary number

0 000

1 001

2 010

3 011

4 100

5 101

6 110

7 111
Hexadecimal number system
• Uses numerals, 0 to 9 & alphabets, A to F
• Has a base of 16
• A positional weighted system, weight of each
position is expressed as powers of 16
• Use the subscript 16 or h following a
hexadecimal no
• Eg: (FAC2)16, (564)16, (0ABD5)16, FAC2h, 564H
• Used in microprocessors and microcontrollers
(Embedded system) where they take input as
hex numbers, process it by converting them
into binary, store it, and display the same in
hex numbers again
• Groups of four (binary) digits can be used to
represent each hexadecimal digit.
Number systems

• Base-10 number system – Decimal (358)10


• Base-2 number system – Binary (0101)2
• Base-8 number system – Octal (671)8
• Base-16 number system – Hexadecimal (3A8)16

• Instead of Base, word ‘radix’ is also used


• 1) Binary to decimal
• 2) Binary to octal
• 3) Binary to Hexadecimal
1. Binary to Decimal conversion

• Converted to their decimal equivalents by the


positional weights method.
• Here each binary digit (bit) of the number is
multiplied by its position weight & the product
terms are added to obtain the decimal number.
• 101012
= (1×24) + (0×23) + (1×22) + (0×21) + (1×20)
= (1×16)+(0×8)+(1×4)+(0×2)+(1×1)
= 16 + 0 + 4 + 0+ 1
= 2110
• 11011.1012
= (1×24)+(1×23)+(0×22)+(1×21)+(1×20) + (1×2-1)+
(0×2-2)+(1×2-3)
= (1×16)+(1×8)+(0×4)+(1×2)+(1×1) + (1×1⁄2)+
(0×1⁄4)+(1×1⁄8)
= 16 + 8 + 0 + 2 + 1 + 0.5 + 0 + 0.125
= 27.62510
Solve the following problems
1. Binary to Decimal conversion

QUESTIONS Answer
1. 11011012 1.10910
2.0.687510
2. 0.10112
3.2.87510
3. 10.1112
2. Binary to Octal conversion
• Simply break the binary number into 3 bit
groups, starting at the right most bit &
replace each 3 bit group with the equivalent
octal digit
• 1101012 Octal Number Binary number

110101
0 000
= 658 1 001

2 010

3 011

4 100

5 101

6 110

7 111
• 11110101011.00112
11110101011.0011
= 011110101011.001100
= 3653.148
Solve the following problems
2. Binary to Octal conversion
• Convert the following binary no to octal
• 1) 101111001
= 5718
• 2) 1001100.11010
= 114.648
• 3) 11010000100
= 32048
3. Binary to Hexadecimal
conversion
• Simply break the binary no into 4 bit
groups, starting at the right most bit &
replace each 4 bit group with the equivalent
hexadecimal digit
• 11001010010101112

• 1100101001010111
= CA5716
• Convert the following binary no to
hexadecimal
• 1) 1111110001011010012
= 3F16916
• 2) 01011111011.0111112
= 2FB.7C16
• 4) Decimal to Binary
• 5) Decimal to octal
• 6) Decimal to Hexadecimal
4. Decimal to Binary Conversion
• Decimal integer number is converted to
binary integer number by successive division
by 2 & decimal fraction is converted to binary
fraction by successive multiplication by 2.
• Known as double-dabble method
• The given decimal integer number is successively
divided by 2 till the quotient is zero. The last
remainder is the MSB .
• The remainders read from bottom to top give the
equivalent binary integers
• The given decimal fractions are successively
multiplied by 2 till the fractional part of the
product is zero.
• The first integer obtained is the MSB. The integers
read from top to bottom give the equivalent binary
fraction. Then combine them.
Solve the following problems
Decimal to Binary conversion
• Convert 5210 to binary
– Ans: 1101002
• Convert 0.7510 to binary
– Ans: 0.112
• Convert 105.1510 to binary
– Ans: 1101001.0010012
• Convert 163.87510 to binary
• Ans: 10100011.1112
• Convert 21.37510 to binary
5. Decimal to Octal conversion
• Repeated division of a decimal no by 8 will
produce the equivalent octal no formed by
the remainders of the divisions
• The first remainder produced is the LSD
• Convert the decimal numbers to octal
• 1) 35910
• 2) 378.9310
6. Decimal to Hexadecimal
Conversion
• Repeated division of a decimal number by 16
will produce the equivalent hexadecimal no
formed by the remainders of the divisions
• The first remainder produced is the LSD
• Convert the decimal numbers to hexadecimal
• 1) 65010
• 2) 2598.67510
• 3) 259110
• 7) Octal to Binary
• 8) Octal to Decimal
• 9) Octal to Hexadecimal
7. Octal to binary conversion
• Reverse the process & replace each octal no
with the appropriate 3 bits
Convert the following octal
numbers to binary
• 1) 138
– 0010112
• 2) 258
– 0101012
• 3) 1408
– 0011000002
• 4) 75268
– 1111010101102
8. Octal to Decimal conversion
• Done by multiplying each digit by its weight
& summing the products
• Convert the following octal numbers to
decimal
• 1) 23748
– 127610
• 2) 4057.068
– 2095.0937510
9. Octal to Hexadecimal
conversion
• Convert Octal to binary and then binary to
Hexadecimal
• OR
• Convert Octal to decimal and then decimal to
Hexadecimal
• Convert 5368 to hexadecimal number
1) Convert 536 into its binary equivalent
5368 = 101 011 110
=1010111102
2)Now forming the group of 4 binary bits
to obtain its hexadecimal equivalent,
1010111102= 0001 0101 1110
= 15E16
• So the hexadecimal number of 5368 is 15E16.
• 10) Hexadecimal to Binary
• 11) Hexadecimal to Decimal
• 12) Hexadecimal to Octal
10. Hexadecimal to Binary
Conversion
• Reverse the process & replace each
hexadecimal no with the appropriate 4 bits
• Convert the following hexadecimal no to
binary
• 1) 10A416
– 00010000101001002
• 2) CF8E16
– 11001111100011102
• 3) 974216
– 10010111010000102
11. Hexadecimal to Decimal
Conversion
• 2 methods
• First convert the hexadecimal no to binary &
then binary to decimal
• Convert the following hexadecimal numbers
to decimal
• 1) 1C16
– 2810
• 2) A8516
– 269310
• Another way is to multiply the decimal value of
each hexadecimal digit by its weight & then
take the sum of these products
• The weights of a hexadecimal no are increasing
powers of 16
• Convert the following hexadecimal numbers to
decimal
• 1) 1C16
– 2810
• 2) A8516
– 269310
• 3) A0F9.0EB16
– 41209.057210
12. Hexadecimal to Octal
Conversion
• Convert Hexadecimal to binary and then
binary to Octal

You might also like