Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMP2130 Winter 2015 Storing signed numbers in memory.

Similar presentations


Presentation on theme: "COMP2130 Winter 2015 Storing signed numbers in memory."— Presentation transcript:

1 COMP2130 Winter 2015 Storing signed numbers in memory

2 Single Precision Floats IEEE 754 32 Bit

3 Floating Point (32 bit) Mantissa (0-22) Exponent (23-30) Signed bit (31) 0 = positive 1 = negative

4 Floating Point (32 bit) 0  Convert 173.7  Positive so sign bit 31 = 0

5 Floating Point (32 bit) Convert 173.7 Positive so bit 31 = 0 Need to convert to 1.xxxxxx number 0

6 Floating Point (32 bit) Convert to 1.xxxxxx number 173.7 / 2 = 86.85 2 1 86.85 / 2 = 43.425 2 2 43.425 / 2 = 21.7125 2 3 21.7125 / 2 = 10.85625 2 4 10.85625 / 2 = 5.428125 2 5 5.428125 / 2 = 2.7140625 2 6 2.7140625 / 2 = 1.35703125 2 7 >= 1.0 use Log 2 (173.7), 173.7/2 x 0

7 Floating Point (32 bit) 173.7 = 1.35703125x2 7 Time to fill in the exponent Has a bias of 127 127 + 7 = 134 134 in unsigned 8 bit binary is 10000110 0

8 Floating Point (32 bit) 173.7 = 1.35703125x2 7 Time to fill in the exponent Has a bias of 127 127 + 7 = 134 134 in unsigned 8 bit binary is 10000110 010 000110

9 Floating Point (32 bit) 1.35703125x2 7 Now we will need to deal with the orange part of the number which will be placed into the mantissa 010 000110

10 Floating Point (32 bit) 010 000110 Numberx2Whole 0.357031250.71406250 0

11 Floating Point (32 bit) 010 000110 Numberx2Whole 0.357031250.71406250 1.4281251 01

12 Floating Point (32 bit) 010 000110 Numberx2Whole 0.357031250.71406250 1.4281251 0.4281250.856250 010

13 Floating Point (32 bit) 010 000110 Numberx2Whole 0.357031250.71406250 1.4281251 0.4281250.856250 1.71251 0110

14 Floating Point (32 bit) 010 000110 Numberx2Whole 0.357031250.71406250 1.4281251 0.4281250.856250 1.71251 0.71251.4251 01110

15 Floating Point (32 bit) 010 000110 Numberx2Whole 0.357031250.71406250 1.4281251 0.4281250.856250 1.71251 0.71251.4251 0.4250.850 011100

16 Floating Point (32 bit) 010 000110 Numberx2Whole 0.357031250.71406250 1.4281251 0.4281250.856250 1.71251 0.71251.4251 0.4250.850 1.71 0111100

17 Floating Point (32 bit) 010 000110 Numberx2Whole 0.357031250.71406250 1.4281251 0.4281250.856250 1.71251 0.71251.4251 0.4250.850 1.71 0.71.41 01111100

18 Floating Point (32 bit) 010 000110 Numberx2Whole 0.357031250.71406250 1.4281251 0.4281250.856250 1.71251 0.71251.4251 0.4250.850 1.71 0.71.41 0.40.80 011111000

19 Floating Point (32 bit) 010 000110 Numberx2Whole 0.357031250.71406250 1.4281251 0.4281250.856250 1.71251 0.71251.4251 0.4250.850 1.71 0.71.41 0.40.80 1.61 0111111000

20 Floating Point (32 bit) 010 000110 Numberx2Whole 0.357031250.71406250 1.4281251 0.4281250.856250 1.71251 0.71251.4251 0.4250.850 1.71 0.71.41 0.40.80 1.61 0.61.21 01111111000

21 Floating Point (32 bit) 010 000110 Numberx2Whole 0.357031250.71406250 1.4281251 0.4281250.856250 1.71251 0.71251.4251 0.4250.850 1.71 0.71.41 0.40.80 1.61 0.61.21 0.20.40 011111110000

22 Floating Point (32 bit) 010 000110 Numberx2Whole 0.357031250.71406250 1.4281251 0.4281250.856250 1.71251 0.71251.4251 0.4250.850 1.71 0.71.41 0.40.80 1.61 0.61.21 0.20.40 011111110000

23 Floating Point (32 bit) 010 000110 Numberx2Whole 0.357031250.71406250 1.4281251 0.4281250.856250 1.71251 0.71251.4251 0.4250.850 1.71 0.71.41 0.40.80 1.61 0.61.21 0.20.40 01111111010010110000110

24 Floating Point (32 bit) 173.7 = 0 10000110 01011011011001100110011

25 Floating Point (32 bit) What if 173.7 was -173.7?

26 Floating Point (32 bit) What if 173.7 was -173.7? 173.7 = 0 10000110 01011011011001100110011

27 Floating Point (32 bit) What if 173.7 was -173.7? 173.7 = 0 10000110 01011011011001100110011 -173.7 = 1 10000110 01011011011001100110011


Download ppt "COMP2130 Winter 2015 Storing signed numbers in memory."

Similar presentations


Ads by Google