Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Number Conversion and Representations, Slides of Computer Architecture and Organization

Algorithms and examples for converting numbers from one base to another, including base 10, base 16, and base c. It also covers converting base b fractions to base c and vice versa. Additionally, it discusses different number representations such as sign-magnitude, radix complement, and diminished radix complement.

Typology: Slides

2011/2012

Uploaded on 11/03/2012

dharmaraaj
dharmaraaj 🇮🇳

4.4

(65)

153 documents

1 / 23

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Converting from Base b
to Base c
Start with base b
representation Initialize base c
value x to 0
Get next xi
Going from
left to right
Convert (xi)b
number (Di)c
by using table
Update the base c
value by
x=xb+Di
Initialize base c
value x to 0
Repeat for
All digits
x m-1…x1x0
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17

Partial preview of the text

Download Number Conversion and Representations and more Slides Computer Architecture and Organization in PDF only on Docsity!

1

Converting from Base b

to Base c

Start with base b representation

Initialize base c value x to 0

Get next xi Going from left to right

Convert (xi) (^) b number (D (^) i) (^) c by using table

Update the base c value by x=xb+D (^) i

Initialize base c value x to 0

Repeat for All digits

x (^) m-1…x1x (^0)

2

Example: Convert the Hexadecimal

number B3 16 to base

10

Solution:

According to the above algorithm,

X=

X=x+B(=11)=

X=16*11+3= 179

Hence B3 16 =179 (^10)

4

Example: convert 390 10 to base 16

c=10, b=

Solution:

According to the above algorithm

390/16 =24( rem=6), x 0 =

24/16= 1(rem=8), x 1 =8, x 2 =

Thus 390 10 =186 16

5

Converting a Base b fraction to calculator’s Base c

Start with base b representation

Initialize f=0.0 and Set i = -m

Convert to Base c number (Di) (^) c by using table

Update f=(f+D)/b And i=i+

Repeat for all digits until i= Here the digits are treated from right to left, with division implemented at each step

f (^) -1 f (^) -2 …f (^) -m x (^) n-1x (^) n-2…x 1 x 0 .x-1 x (^) -2 …x-m

7

Converting a fraction from calculator’s Base c to Base b

Start with fraction f in Base c Initialize i=1 and v=f

Set D (^) -i=bv  and v=bv - D (^) i Convert D (^) i to f-i

Set i=i+ If v!=0 repeat Until enough digits are generated

No division is required and the process should be terminated when enough digits are generated

8

Example: Convert 0.24 10 to base 2

Solution:

0.24*2=0.48, f-1=

0.48*2=0.96, f-2=

0.96*2=1.92, f-3=

0.92*2=1.84, f-4=

0.84*2=1.68, f-5=1,…

Thus 0.24 10 =(0.00111) 2

10

Radix Complement

  • This is the most common representation
  • Given an m-digit base b number x, the radix complement of x is xc= ( b m^ – x) mod bm
  • This representation makes the arithmetic operations much easier

11

Diminished Radix Complement

  • The diminished radix complement of an m-digit number x is xc’^ =b m-1-x
  • This complement is easier to compute than the radix complement
  • The two complement operations are interconvertible, as xc= ( x c’^ +1)mod b m

13

Example Base 2 Complement representation

Number Representation Number Representation

0 0 0 0 or 255

0<x<128 x 0<x<128 x

-128<=x<0 256-|x| -127<=x<0 255 -|x|

8 bit 2’s complement 8 bit 1’s complement

14

Examples of number representations

Decimal 2’s complement

1’s complement

Sign- magnitude

16’s complement

Unsigned

27 011011 011011 011011 1B 11011

.17 0.00101011^ 0.00101011^ 0.00101011^ 0.2B 0.

-26 100110 100101 111010 E6 -

-0.57 1.01101110 1.01101101 1. 10

F.6E -

16

Example: Multiplication and division of negative numbers

  • -6x

-6=(11010) (^2) -6x4=(01000) 2 =8 which is wrong! using less no. of bits might change sign

So, -6=(111010) (^2)

-6x4=(101000) 2 = -

17

Example: Multiplication and division of negative numbers

  • -24x

-24=(101000) (^2) -24x2=(010100) 2 = -24x2=(110100) 2 = -

Changing the size of the number,

24=011000 (n=6) to 00011000 (n=8) -24=101000 (n=6) to 11101000 (n=8)

19

Example: unsigned

addition in Base 2 and 16

Base 16 addition Base 2 addition

A B 4 2 16

  • 3 1 C 1 16 0 1 0 D D 0 3 16

20

Addition Hardware Base b unsigned digit adder

(x (^) j+y (^) j+c (^) j)/b (x (^) j+y (^) j+c (^) j)mod b

x (^) j y (^) j

0<=cj+1 <=

0<=s (^) j<=b

0<=cj<=