0% found this document useful (0 votes)
21 views24 pages

Lec 04 Slides

Uploaded by

Joshua Adekunjo
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)
21 views24 pages

Lec 04 Slides

Uploaded by

Joshua Adekunjo
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/ 24

Converting Decimal Fractions to Other Bases

Converting .7812510 to Binary


Converting Decimal Fractions to Other Bases
Converting .7812510 to Binary Convert Binary to Hex Converting .7812510 directly to Hex

.78125 x 2 = 1.5625 .7812510 = .110012 .78125 x 16 = 12.5


.5625 x 2 = 1.125 .5 x 16 = 8.0
. 1 1 0 0 1 0 0 0 2
.125 x 2 = 0.25
.25 x 2 = 0.5 . C 8
.5 x 2 = 1.0
.7812510 = .110012 = .C816
Converting Decimal Fractions to Other Bases
Converting .3610 to Hex

.36 x 16 = 5.76
.3610 = .5C28F16 = .0101 1100 0010 1000 11112
.76 x 16 = 12.16
.16 x 16 = 2.56
.56 x 16 = 8.96
.96 x 16 = 15.36
.36 x 16 = 5.76
.76 x 16 = 12.16
.
.
.
Converting Integers in Other Bases to Decimal
Converting 10110102 to Decimal
Converting Integers in Other Bases to Decimal
Converting 10110102 to Decimal
6 5 4 3 2 1 0
1 0 1 1 0 1 0

= 1 x 26 + 0 x 25 + 1 x 24 + 1 x 23 + 0 x 22 + 1 x 21 + 0 x 20

= 1 x 64 + 0 x 32 + 1 x 16 + 1 x 8 + 0 x 4 + 1 x 2 + 0 x 1

= 64 + 16 + 8 + 2

= 9010
Converting Integers in Other Bases to Decimal
Converting 10110102 to Decimal
6 5 4 3 2 1 0
1 0 1 1 0 1 0

= 26 + 24 + 23 + 21

= 64 + 16 + 8 + 2

= 90
Converting Integers in Other Bases to Decimal
Converting 1010110102 to 15A16 to Decimal
2 1 0
1 5 A

= 1 x 162 + 5 x 161 + 10 x 160

= 1 x 256 + 5 x 16 + 10 x 1

= 256 + 80 + 10

= 34610
Converting Fractions in Other Bases to Decimal
Converting .1011012 to Decimal
Converting Fractions in Other Bases to Decimal
Converting .1011012 to Decimal
-1 -2 -3 -4 -5 -6
. 1 0 1 1 0 1

= 1 x 2-1 + 0 x 2-2 + 1 x 2-3 + 1 x 2-4 + 0 x 2-5 + 1 x 2-6

= 1 x 1/2 + 0 x 1/4 + 1 x 1/8 + 1 x 1/16 + 0 x 1/32 + 1 x 1/64

= 1 x .5 + 0 x .25 + 1 x .125 + 1 x .0625 + 0 x .03125 + 1 x .015625

= 0.70312510
Converting Fractions in Other Bases to Decimal
Converting .1011012 to B416 to Decimal
-1 -2
. B 4

= B x 16-1 + 4 x 16-2

= 11 x 1/16 + 4 x 1/256

= 11 x .0625 + 4 x .00390625

= 0.70312510
Converting Integers in Other Bases to Decimal using Horner’s Method
Converting 715A16 to Decimal
3 2 1 0
7 1 5 A

= (((((7 x 16) + 1) x 16) + 5) x 16) + 10

= 2901810

= 7 x 163 + 1 x 162 + 5 x 161 + 10 x 160 ?


Converting Integers in Other Bases to Decimal using Horner’s Method
Converting 715A16 to Decimal
3 2 1 0
7 1 5 A

= ((((7 x 16 + 1) x 16) + 5) x 16) + 10

= ((((7 x 16 x 16 + 1 x 16)) + 5) x 16) + 10

= ((7 x 162 + 1 x 16 + 5) x 16) + 10

= ((7 x 163 + 1 x 162 + 5 x 16)) + 10

= 7 x 163 + 1 x 162 + 5 x 161 + 10 x 160

= 2901810
Converting Numbers in Other Bases to Decimal using Horner’s Method
Converting 715A16 to Decimal

7 1 5 A

= ((((7 x 16 + 1) x 16) + 5) x 16) + 10

= 2901810

Converting 0.5C4316 to Decimal

.5 C 4 3

= (((((3 / 16 + 4) / 16) + 12) / 16) + 5) / 16

= 0.360397338867187510
Unsigned Binary Addition
Adding 17310 to 7810 using binary: Adding 23710 to 20610 using binary:

173 1010 1101 237 1110 1101


+ 78 +0100 1110 + 206 +1100 1110
Unsigned Binary Addition
Adding 17310 to 7810 using binary: Adding 23710 to 20610 using binary:

1 1 1 1 1
173 1010 1101 237 1110 1101
+ 78 +0100 1110 + 206 +1100 1110
251 1111 1011 443 11011 1011 187 in 8 bits
(overflow)

Range of n-bit unsigned binary numbers


0000 0000 to 1111 1111
Unsigned Binary Subtraction
Subtracting 7810 from 17310 using binary: Subtracting 17310 from 7810 using binary:

173 1010 1101 78 0100 1110


- 78 - 0100 1110 - 173 - 1010 1101
95
Unsigned Binary Subtraction
Subtracting 7810 from 17310 using binary: Subtracting 17310 from 7810 using binary:
2 2 2
-1 2 -1-1 -1 -1 2 -1 2 -1 2 -1 2
173 1010 1101 78 0100 1110
- 78 - 0100 1110 - 173 - 1010 1101
95 0101 1111 10100001
Note borrow out of the Msb
Subtraction by adding the Two’s Complement
510 - 210 = 310

0000
111

1
000
1
0101

10
11

- 0010

00
10

= 0011
110 1
1 001

1100 0100 -2

1 010
101 1
10

01
10

10
1

011
1000
100

1
Subtraction by adding the Two’s Complement
510 - 210 = 310

0000
111

1
000
1
0101 0101

10
11

- 0010 + 1110

00
10

= 0011 = 10011
110 1
1 001

1100 0100 -2

1 010
101 1
10

01
10

10
1

011
1000
100

+14
1
Subtraction by adding the Two’s Complement
510 - 210 = 310

0000
111

1
000
1
0101 0101

10
11

- 0010 + 1110

00
10

= 0011 = 10011
110 1
1 001

1100 0100 -2

1 010
101 1
10

01
10

10
1

011

14 = 16 - 2 = 24 - 2
1000
100

+14
1

Definition: 2’sC(N) = 2n - N for n-bit numbers


Signed Numbers
Signed Signed
UnSigned Magnitude 2’s Comp
0000 0 +0 +0
0001 1 +1 +1
0010 2 +2 +2
0011 3 +3 +3
0100 4 +4 +4
0101 5 +5 +5
0110 6 +6 +6
0111 7 +7 +7
1000 8 -0 -8
1001 9 -1 -7
1010 10 -2 -6
1011 11 -3 -5
1100 12 -4 -4
1101 13 -5 -3
1110 14 -6 -2
1111 15 -7 -1

Range: 0 to 2n - 1 -2(n-1) - 1 to -2(n-1) to


2(n-1) - 1 2(n-1) - 1
Adding Signed 2’s Complement Numbers
Adding -8310 to +7810 :

83 = 0 1 0 1 0 0 1 1 78 = 0 1 0 0 1 1 1 0

-83 =
Adding Signed 2’s Complement Numbers
Adding -8310 to +7810 : Adding +10910 to +7810 :

83 = 0 1 0 1 0 0 1 1 78 = 0 1 0 0 1 1 1 0 109 0110 1101


+ 78 + 0100 1110

1 1011 1011
-83 = 1 0 1 0 1 1 0 1

-83 1010 1101


+ 78 + 0100 1110
? 1111 1011
Adding Signed 2’s Complement Numbers
Adding -8310 to +7810 : Adding +10910 to +7810 :

83 = 0 1 0 1 0 0 1 1 78 = 0 1 0 0 1 1 1 0 109 0110 1101


+ 78 + 0100 1110
-69 1011 1011
-83 =

-83 1010 1101 109 00110 1101


+ 78 + 0100 1110 + 78 + 0 0 1 0 0 1 1 1 0

? 1111 1011 187 01011 1011

8-bit Signed 2’s Complement Range: -27 to +27-1 = -128 to +127

When adding two positive Signed 2’s Complement numbers, overflow occurs when the result is negative.
When adding two negative Signed 2’s Complement numbers, overflow occurs when the result is positive.
When adding a positive and a negative Signed 2’s Complement number, there can never be overflow.

Author’s “easy” way to know when overflow occurs: Overflow occurs when the carry-in and carry-out of the sign-bit (MSb) differ.

You might also like