tutorial 2 including lecture on division also try the 2009 ... · tutorial 2 –including lecture...

19
Tutorial 2 including lecture on division Also try the 2009 tutorial slides for more exercises!

Upload: others

Post on 07-Sep-2019

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Tutorial 2 including lecture on division Also try the 2009 ... · Tutorial 2 –including lecture on division Also try the 2009 tutorial slides for more exercises!

Tutorial 2 – including lecture on division

Also try the 2009 tutorial slides for more exercises!

Page 2: Tutorial 2 including lecture on division Also try the 2009 ... · Tutorial 2 –including lecture on division Also try the 2009 tutorial slides for more exercises!

Transform to binary:

4128

3678

12416

DCB16

Page 3: Tutorial 2 including lecture on division Also try the 2009 ... · Tutorial 2 –including lecture on division Also try the 2009 tutorial slides for more exercises!

4128 = 100001010

3678 = 011110111

12416 = 000100100100

DCB16 = 110111001011

Page 4: Tutorial 2 including lecture on division Also try the 2009 ... · Tutorial 2 –including lecture on division Also try the 2009 tutorial slides for more exercises!

Transform from Octal to Hexadecimal

777.7778

123.4568

Transform from Hexadecimal to Octal

9E4616

ABC.DEF16

Page 5: Tutorial 2 including lecture on division Also try the 2009 ... · Tutorial 2 –including lecture on division Also try the 2009 tutorial slides for more exercises!

Transform from Octal to Hexadecimal

777.7778 = 1FF.FF816

123.4568 = 53.9716

Transform from Hexadecimal to Octal

9E4616 = 1171068

ABC.DEF16 = 5274.67578

Page 6: Tutorial 2 including lecture on division Also try the 2009 ... · Tutorial 2 –including lecture on division Also try the 2009 tutorial slides for more exercises!

◦ Steps (long division): The divisor must be a whole number. If it is not, then we

will multiply (or shifting) it so that it becomes one. And Multiply (shifting) the dividend by the same power Example: 10.1101 / 1.01 => 1011.01 / 101 Answer = 10.01

10.01101 | 1011.01

- 10101 (101 goes zero times into 01)

- 0 1 0 (101 goes zero times into 10)

- 0101

- 1010 (division complete)

Page 7: Tutorial 2 including lecture on division Also try the 2009 ... · Tutorial 2 –including lecture on division Also try the 2009 tutorial slides for more exercises!

0111.100100100….111)110101

- 1111100

- 1111011

- 1111000

- 11100010

- 0100

- 01000

- 1111, etc…

Page 8: Tutorial 2 including lecture on division Also try the 2009 ... · Tutorial 2 –including lecture on division Also try the 2009 tutorial slides for more exercises!

Complete the following division:

1000)1111100

Page 9: Tutorial 2 including lecture on division Also try the 2009 ... · Tutorial 2 –including lecture on division Also try the 2009 tutorial slides for more exercises!

1111.11000)1111100

100001111100001110100001100

10000100010000000

Page 10: Tutorial 2 including lecture on division Also try the 2009 ... · Tutorial 2 –including lecture on division Also try the 2009 tutorial slides for more exercises!

Question 5:

Answer the follow computing (6 bits used):

001010 AND 010100

010101 OR 100010

110110 XOR 001111

NOT(110010 XOR 110011)

Page 11: Tutorial 2 including lecture on division Also try the 2009 ... · Tutorial 2 –including lecture on division Also try the 2009 tutorial slides for more exercises!

Answers:

001010 AND 010100 = 000000

010101 OR 100010 = 110111

110110 XOR 001111 = 111001

NOT(110010 XOR 110011) = 111110

Page 12: Tutorial 2 including lecture on division Also try the 2009 ... · Tutorial 2 –including lecture on division Also try the 2009 tutorial slides for more exercises!

Answer the 6-bit shift operations:

(Java shifting symbol convention):◦ Shift left logical: <<

◦ Shift right logical (zero fill): >>>

◦ Shift right arithmetic (signed shift): >>

000100 >> 2

110110 << 1

100110 >>> 3

Page 13: Tutorial 2 including lecture on division Also try the 2009 ... · Tutorial 2 –including lecture on division Also try the 2009 tutorial slides for more exercises!

000100 >> 2 = 110001

110110 << 1 = 011000

100110 >>> 3 = 000100

Page 14: Tutorial 2 including lecture on division Also try the 2009 ... · Tutorial 2 –including lecture on division Also try the 2009 tutorial slides for more exercises!

Avogadro’s number (6.02 x 1023) requires 80 bits to be represented in two’s complement binary representation.

Method: log2(6.02 x 1023) ≈ 78.99 ≈ 79

Add the sign bit gives 80 bits for a 2’s complement representation.

Page 15: Tutorial 2 including lecture on division Also try the 2009 ... · Tutorial 2 –including lecture on division Also try the 2009 tutorial slides for more exercises!

Exercise 6: Convert C134000016 from IEEE 754 Floating Point (Single Precision) to decimal

Exercise 7: Convert 3.625 from Decimal to IEEE 754 Floating Point (Single Precision)

Page 16: Tutorial 2 including lecture on division Also try the 2009 ... · Tutorial 2 –including lecture on division Also try the 2009 tutorial slides for more exercises!

Exercise 6: Convert C134000016 from IEEE 754 Floating Point (Single Precision) to decimal = -11.25

Exercise 7: Convert 3.625 from Decimal to IEEE 754 Floating Point (Single Precision)

= 4068000016

Some working on the next slides ->

Page 17: Tutorial 2 including lecture on division Also try the 2009 ... · Tutorial 2 –including lecture on division Also try the 2009 tutorial slides for more exercises!

Exercise 6: Convert C134000016 from IEEE 754 Floating Point (Single Precision) to decimal = -11.25

=1/10000010/0110100 0000 0000 0000 0000

128 +2 = 130, 130 -127 = 3

1.0 + . 01101 = 1.01101 <<3 = 1011.01

Final answer: -1011.01 = - 11.25

Page 18: Tutorial 2 including lecture on division Also try the 2009 ... · Tutorial 2 –including lecture on division Also try the 2009 tutorial slides for more exercises!

Exercise 7: Convert 3.625 from Decimal to IEEE 754 Floating Point (Single Precision)

11.101 => 1.1101 x 2^1

Magnitude: 1 + 127 = 128 => 10000000

0100 0000 0110 1000 0000 0000 0000 0000

=> 40680000

Page 19: Tutorial 2 including lecture on division Also try the 2009 ... · Tutorial 2 –including lecture on division Also try the 2009 tutorial slides for more exercises!