Class Notes (836,991)
Canada (510,026)
CS 230 (51)
Adel Fakih (16)
Lecture

CS 230 tutorial3_solutions.pdf

7 Pages
148 Views
Unlock Document

Department
Computer Science
Course
CS 230
Professor
Adel Fakih
Semester
Fall

Description
CS230 Fall 2012 - Tutorial 3 Solutions Monday, Oct 1, 2012 1 Floating Point Representation Steps skipped in later sections can be verified at http://babbage:cs:qc:cun y:edu/IEEE-754/ for converting to/from IEEE-754, and http://www:exp loringbinary:com/binary-converter/ for working with binary num- bers with fractional parts. 1. (a) 41.3267 41 / 2 = 20 R 1 20 / 2 = 10 R 0 10 / 2 = 5 R 0 5 / 2 = 2 R 1 2 / 2 = 1 R 0 1 / 2 = 0 R 1 ! 41 = 1010012 0.3267 ▯ 2 = 0.6534 0.6534 ▯ 2 = 1.3068 0.3068 ▯ 2 = 0.6136 0.6136 ▯ 2 = 1.2272 0.2272 ▯ 2 = 0.4544 0.4544 ▯ 2 = 0.9088 0.9088 ▯ 2 = 1.8176 0.8176 ▯ 2 = 1.6352 0.6352 ▯ 2 = 1.2704 0.2704 ▯ 2 = 0.5408 0.5408 ▯ 2 = 1.0816 0.0816 ▯ 2 = 0.1632 0.1632 ▯ 2 = 0.3264 0.3264 ▯ 2 = 0.6528 0.6528 ▯ 2 = 1.3056 1 0.3056 ▯ 2 = 0.6112 0.6112 ▯ 2 = 1.2224 0.2224 ▯ 2 = 0.4448 ! .3267 = .010100111010001010... 2 41.3267 = 101001.010100111010001010 5 = 1.01001010100111010001010 ▯ 2 Sign = 0 (+) Exponent = 5 + bias = 5 + 127 = 132 = 10000100 Significand = 01001010100111010001010 41.3267 = 0 10000100 01001010100111010001010 (b) -987.2 987 / 2 = 493 R 1 493 / 2 = 246 R 1 246 / 2 = 123 R 0 123 / 2 = 61 R 1 61 / 2 = 30 R 1 30 / 2 = 15 R 0 15 / 2 = 7 R 1 7 / 2 = 3 R 1 3 / 2 = 1 R 1 1 / 2 = 0 R 1 ! 987 = 1111011011 2 0.200000 ▯ 2 = 0.400000 0.400000 ▯ 2 = 0.800000 0.800000 ▯ 2 = 1.600000 0.600000 ▯ 2 = 1.200000 0.200000 ▯ 2 = 0.400000 ... repeats ... ! 0.2 = 0.0011 0011 0011 .2. 987.2 = 1111011011.00110011001100 9 = 1.11101101100110011001100 ▯ 2 Sign = 1 (-) Exponent = 9 + bias = 9 + 127 = 136 = 10001000 Significand = 11101101100110011001100 -987.2 = 1 10001000 11101101100110011001100 (c) 6 2 6 / 2 = 3 R 0 3 / 2 = 1 R 1 1 / 2 = 0 R 1 ! 6 = 1102 0.0 ! 0.0 = 0.02 2 6.0 = 110.0 = 1.100 ▯ 2 Sign = 0 (+) Exponent = 2 + bias = 2 + 127 = 129 = 10000001 Significand = 10000000000000000000000 6.0 = 0 10000001 10000000000000000000000 (d) 0.0000048 0 = 02 0.0000048 ▯ 2 = 0.0000096 0.0000096 ▯ 2 = 0.0000192 0.0000192 ▯ 2 = 0.0000384 0.0000384 ▯ 2 = 0.0000768 0.0000768 ▯ 2 = 0.0001536 0.0001536 ▯ 2 = 0.0003072 0.0003072 ▯ 2 = 0.0006144 0.0006144 ▯ 2 = 0.0012288 0.0012288 ▯ 2 = 0.0024576 0.0024576 ▯ 2 = 0.0049152 0.0049152 ▯ 2 = 0.0098304 0.0098304 ▯ 2 = 0.0196608 0.0196608 ▯ 2 = 0.0393216 0.0393216 ▯ 2 = 0.0786432 0.0786432 ▯ 2 = 0.1572864 0.1572864 ▯ 2 = 0.3145728 0.3145728 ▯ 2 = 0.6291456 0.6291456 ▯ 2 = 1.2582912 0.2582912 ▯ 2 = 0.5165824 0.5165824 ▯ 2 = 1.0331648 0.0331648 ▯ 2 = 0.0663296 0.0663296 ▯ 2 = 0.1326592 0.1326592 ▯ 2 = 0.2653184 3 0.2653184 ▯ 2 = 0.5306368 0.5306368 ▯ 2 = 1.0612736 0.0612736 ▯ 2 = 0.1225472 0.1225472 ▯ 2 = 0.2450944 0.2450944 ▯ 2 = 0.4901888 0.4901888 ▯ 2 = 0.9803776 0.9803776 ▯ 2 = 1.9607552 0.9607552 ▯ 2 = 1.9215104 0.9215104 ▯ 2 = 1.8430208 0.8430208 ▯ 2 = 1.6860416 0.6860416 ▯ 2 = 1.3720832 0.3720832 ▯ 2 = 0.7441664 0.7441664 ▯ 2 = 1.4883328 0.4883328 ▯ 2 = 0.9766656 0.9766656 ▯ 2 = 1.9533312 0.9533312 ▯ 2 = 1.9066624 0.9066624 ▯ 2 = 1.8133248 0.8133248 ▯ 2 = 1.6266496 ! 0.0000048 = 0.00000000000000000101000010000111110101111 2 ▯18 = 1.01000010000111110101111 ▯ 2 Sign = 0 (+) Exponent = -18 + bias = -18 + 127 = 109 = 01101101
More Less

Related notes for CS 230

Log In


OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.


Submit