Docsity

Discussion 1.1 for ECE 120, Exercises of Computer Programming

Toggle sidebar
bg1
Your Name: __________________________________ netid:________________ Group #:
Name: ______________________________________ netid:________________
Name: ______________________________________ netid:________________
Name: ______________________________________ netid:________________
1
ECE 120 Worksheet 1: Binary Representation
1. Consider the progressive improvement of computer graphics (like the evolution of Mario
drawn above). Why does increasing from one or two bits per pixel to 24 to 32 bits per pixel
alter the quality of graphics so much? What are these bits encoding?
2. Consider the bit sequence 10111010. What does the sequence represent? Create a list of
possible interpretations
pf3

Partial preview of the text

Download Discussion 1.1 for ECE 120 and more Exercises Computer Programming in PDF only on Docsity!

Your Name: __________________________________ netid:________________ Group #:

Name: ______________________________________ netid:________________

Name: ______________________________________ netid:________________

Name: ______________________________________ netid:________________

ECE 120 Worksheet 1: Binary Representation

1. Consider the progressive improvement of computer graphics (like the evolution of Mario

drawn above). Why does increasing from one or two bits per pixel to 24 to 32 bits per pixel

alter the quality of graphics so much? What are these bits encoding?

2. Consider the bit sequence 10111010. What does the sequence represent? Create a list of

possible interpretations

Unsigned binary representation of integer numbers

  • Let’s look how integers, such as 1, 2, 3, and so on can be represented using binary digits 0 and 1
  • Decimal numbers use base 10 positional notation, e.g., 564 means that there are 5 hundreds, 6 tenths, and 4 ones. Each digit’s position in the number defines if this number is ones, or tenths, or hundreds… o 564 can be writes as 5100 + 610 + 4, or alternatively, 5 *10 2 + 6 *10 1 + 4 *10 0 o Here 10 is the base of the numerical system used o Alternatively, 564 can be written as 564 (^10)
  • Binary numbers work the same way using just two digits, 0 and 1, using base 2 positional notation o 00110 can be written as 0 *2 4 + 0 *2 3 + 1 *2 2 + 1 *2 1 + 0 *2 0 o Notation 00110 2 means that the number is written in binary form o By the way, 00110 2 = 6 (^10) o With k bits we can represent 2 k^ positive integers, ranging from 0 to 2 k -

Unsigned binary to decimal conversion

  • Recall that a binary integer number consisting of k bits is written in the form ak-1a (^) k-2…a 1 a 0 where ai is either 0 or 1 o Example: 11000111 (^2)
  • Compute the decimal number as follows: o A 10 = ak-1 *2 k-1^ + …a 1 *2^1 + a 0 *2^0
  • Example: convert 0111001 2 to the decimal notation: o The magnitude is 02 6 +12^5 +12 4 +12 3 +02 2 +02 1 +1*2 0 =32 10 +16 10 +8 10 +1 10 =

Decimal to unsigned binary conversion

  • The textbook describes a method based on comparing with descending powers of 2 and subtracting
  • A simpler technique is based on short division by 2 with remainder o Start by writing the number to be converted o Divide it by 2 o Write quotient of the division underneath the number o Write remainder of the division next to the number o Repeat last 3 steps until the quotient becomes 0 o Write down the sequence of remainders, starting from the bottom, this is your answer
  • Example: 156 10 =? (^2)

156 0 78 0 39 1 19 1 9 1 4 0 2 0 1 1 0 0

o The answer is 156 10 =010011100 2