tutorial 2 including lecture on division also try the 2009 ... · tutorial 2 –including lecture...
TRANSCRIPT
Tutorial 2 – including lecture on division
Also try the 2009 tutorial slides for more exercises!
Transform to binary:
4128
3678
12416
DCB16
4128 = 100001010
3678 = 011110111
12416 = 000100100100
DCB16 = 110111001011
Transform from Octal to Hexadecimal
777.7778
123.4568
Transform from Hexadecimal to Octal
9E4616
ABC.DEF16
Transform from Octal to Hexadecimal
777.7778 = 1FF.FF816
123.4568 = 53.9716
Transform from Hexadecimal to Octal
9E4616 = 1171068
ABC.DEF16 = 5274.67578
◦ 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)
0111.100100100….111)110101
- 1111100
- 1111011
- 1111000
- 11100010
- 0100
- 01000
- 1111, etc…
Complete the following division:
1000)1111100
1111.11000)1111100
100001111100001110100001100
10000100010000000
Question 5:
Answer the follow computing (6 bits used):
001010 AND 010100
010101 OR 100010
110110 XOR 001111
NOT(110010 XOR 110011)
Answers:
001010 AND 010100 = 000000
010101 OR 100010 = 110111
110110 XOR 001111 = 111001
NOT(110010 XOR 110011) = 111110
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
000100 >> 2 = 110001
110110 << 1 = 011000
100110 >>> 3 = 000100
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.
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)
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 ->
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
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