lab_2_worksheet

doc

School

Langara College *

*We aren’t endorsed by this school

Course

1050

Subject

Computer Science

Date

Feb 20, 2024

Type

doc

Pages

5

Uploaded by GrandGuineaPig4093

Report
Lab 2: Chapter 3, Data Representation — Negative Integers, Non- negative Floating Point Numbers (Fractions), Text, Text Compression. [52 marks] In all of the problems, you must show your work to qualify for the mark. Type your answer in this worksheet after each question. Export the completed worksheet to PDF and Submit the PDF version with D2L. The related Lab Manual PDF files and Applets are included on D2L. It is recommended that you read the PDF Files and try some examples with the Applets. 1. [3 marks] Convert -45 to 8-bit signed magnitude binary notation. Check your answer with "Negative Binary Numbers" Applet. Answer: -45= 10101101 2 2. [4 marks] Convert -45 to 8-bit 2's complement binary notation. Check your answer with "Negative Binary Numbers" Applet. Answer: -45 = 45 = 00101101 = 11010010+1 = 11010011 2 Page 1
3. [9 marks] Convert the following 8-bit signed magnitude binary numbers to decimal. 10101010 00101010=42=-42 00110101 00110101=53 11110100 01110100=116=-116 4. [9 marks] Convert the following 8-bit 2's complement binary numbers to decimal. Note: A non-negative number’s 2’s complement is the same as its sign-magnitude. 10101110 01010001+1=01010010= 82= -82 00110101 11001010+1=11001011= -75= 75 11101010 00010101+1=00010110=22=-22 Page 2
5. [ 2] Convert ˗137 to Binary using "Negative Binary Numbers" Applet. How many Bits would be needed and Why? 6. [5 marks] Convert the decimal 27.137 to binary. Stop after 5 binary digits to the right of the decimal point. 7. [5 marks] Convert the binary 1111.0011 to a decimal number (with fraction). Show the full polynomial first. Answer: 1111.0011 2 = 1*2 3 +1*2 2 +1*2 1 +1*2 0 +0*2 -1 +0*2 -2 +1*2 -3 +1*2 -4 = 8+4+2+1+0.125+0.0625 = 15.1875 10 8. [4 marks] Write your first and last names. What will your name be in ASCII codes. Use hexadecimal. Note that you will need an ASCII table. Page 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
9. [3 marks] Decode the following ASCII coded phrase. These are the decimal numbers for each ASCII character. Note that you will need an ASCII table. 67 111 110 118 101 114 116 105 110 103 32 102 114 111 109 32 65 83 67 73 73 32 99 111 100 101 115 32 116 111 32 116 101 120 116 32 105 115 32 102 117 110 46 32 40 78 79 84 33 41 10. [8] Given the Huffman Encoding table, decode the following bit strings. In each case, calculate the compression ratio if we normally use the 8-bit ASCII code for characters. a. 1101110001011 b. 0110101010100101011111000 c. 10100100101000010001000010100110110 d. 10100010010101000100011101000100011 Page 4 HUFFMAN CODE CHARACTER 00 A 11 E 010 T 0110 C 0111 L 1000 S 1011 R 10010 O 10011 I 101000 N 101001 F 101010 H 101011 D
Submit the PDF version of the completed worksheet with D2L. Page 5