Você está na página 1de 12

Digital Logic Design

Lecture No 04:
Binay, Octal and Hexadecimal numbers, Complements
BSCS-6AB
Dated 15 Feb 2017

By Nasir Mahmood
nasir.mahmood@seecs.edu.pk
nasirm15@gmail.com
Review of Last Lecture
● Numbers System

● Base or radix, Digits from o to R-1

● Conversion of Number Systems

● From Base R to Decimal?

● Expand in power series and adding them

● Conversion from Decimal to Base R?

● Use repeated division for integer part , Use repeated multiplication


for decimal part
Conversion Between two Bases

However, it is generally easier to convert base

A to its decimal equivalent and then convert the

decimal value to base B.

− Base A → Decimal → Base B

Power Series Expansion Repeated Division, Repeated Multiplication


Conversion between binary and Octal
It can be carried out by inspection.

− Each octal digit corresponds to 3 bits

(101 110 010 . 011 001) =2 (5 6 2 . 3 1)8


(010 011 100 . 101 001)2 = (2 3 4 . 5 1)8

(7 4 5 . 3 2)8 = (111 100 101 . 011 010)2


(3 0 6 . 0 5)8 = (011 000 110 . 000 101)2

− Is the number (392.24)8 a valid octal number?


Conversion between binary and
hexadecimal

Each hexadecimal digit corresponds to 4 bits

(1001 1010 0110 . 1011 0101)2 = (9 A 6 . B 5)16


(1100 1011 1000 . 1110 0111)2 = (C B 8 . E 7)16
(E 9 4 . D 2)16 = (1110 1001 0100 . 1101 0010)2
(1 C 7 . 8 F)16 = (0001 1100 0111 . 1000 1111)2

− Note that the hexadecimal number system requires

additional characters to represent its 16 values.


Your Turn

• Please write numbers from 0 to 20 in decimal,


binary, Octal, Hexadecimal
Complements
● Complements are used to simplify subtraction
operations. We do subtraction by adding.

A – B = A+ (-B)

● There are two types:


● The radix complement, called the r’s complement.
● The diminished radix complement, called the (r-1)’s
complement.
Diminished Radix Complement 

or (r-1)’s complement.
● Given a number N in base r having n digits
n
● The (r - 1)'s complement of N is defined as (r - 1) – N
● For Decimal Number System
n
● 9’s Complement is = (10 -1) - N
5
● For example 9’s complement of 53406 = (10 -1) – 53406
= 99999 – 53406 = 46593

● For Binary Number System


n
● 1’s Complement is = (2 – 1) – N
8
● For Example 1’s complement of 10100110 is = (2 – 1) – 10100110


=11111111 – 10100110 = 01011001

● Note that 1’s complement can be done by switching all 0’s to 1’s and 1’s to 0’s
Finding Diminished Radix Complement (DRC)

● The DRC or (r-1)’s complement of decimal number is


obtained by subtracting each digit from 9

● The (r-1)’s complement of octal or hexadecimal


number is obtained by subtracting each digit from 7
or F, respectively

● The DRC (1’s complement) of a binary number is


obtained by subtracting each digit from 1. It can also
be formed by changing 1’s to 0’s and 0’s to 1’s
Radix Complement
● The r’s complement of an n-digit number N in base-r is
defined as:
rn – N - for N ≠ 0
0 - for N = 0

● We may obtain r’s complement by adding 1 to (r-1)’s


complement. Since rn – N = [(rn – 1) – N]+1
● 10’s complement of 3229 is:
104 – 3229 = 6771

● 2’s complement of 101101 is:


26 – 101101 = 010011

● Note that to determine 2’s complement, leave the least


significant 0’s and the first 1 unchanged and then switch
the remaining 1’s to 0’ and 0’s to 1’s.
Notes on Complements
● A couple of notes on complements to keep in mind:
● If you are trying to determine the complement of a value
that contains a radix point:
● Remove the radix point.
● Determine the complement.
● Replace the radix point in the same relative position.
● The complement of a complement will restore the
original number.
The End

Você também pode gostar