Review R: Representing data: Questions

R1.1.

How many bits are in a kilobyte of memory?

R1.2.

Approximate 234 in the form x × 10y, with x and y both being base-10 integers. (Your answer need not be normalized.)

R1.3.

Approximate 245 in the form x × 10y, with x and y both being base-10 integers. (Your answer need not be normalized.)

R1.4.

Approximately how many kilobytes are accessible with a 23-bit address space?

R1.5.

Perform each of the following conversions.

a.101101(2)to decimal
b.1010101(2)to decimal
c.23(10)to binary
d.95(10)to binary
R1.6.

Given that humans almost always use base-10 numbers, while modern computers always work with base-2 numbers, why do programmers often choose to write numbers in base 16?

R1.7.

Perform each of the following conversions. Show your work.

a. 110110(2)to decimal
b. 140(10)to binary
c. E1EC7ED(16)to binary
R1.8.

Perform each of the following conversions.

a.1010101010101(2)to octal
b.10101010101010(2)to hexadecimal
c.101101(2)to hexadecimal
d.560(8)to binary
e.CAB(16)to binary
f.D15EA5ED(16)to binary
R2.1.

Represent each of the following using the 8-bit two's-complement integer representation.

a.10(10)
b.−60(10)
c.−104(10)
R2.2.

Represent each of the following in a two's-complement representation.

a.−1(10) in a seven-bit two's-complement format
b.−20(10) in a seven-bit two's-complement format
c.20(10) in a seven-bit two's-complement format
d.−300(10) in twelve-bit two's-complement format
R2.3.

For the following, assume a six-bit two's-complement representation of integers.

a.What numeric value does 110110 represent?
b.What numeric value does 010101 represent?
c.What bit pattern is used to represent −12(10)?
R2.4.

a. What is the smallest (most negative) number you can represent in seven bits using sign-magnitude representation? Give both the bit pattern of the number and its base-10 translation.

b. Answer the same question for a seven-bit two's-complement representation.

R3.1.

Explain what ASCII is.

R3.2.

In addition to characters, digits, punctuation symbols, and the space character, ASCII also includes some “unprintable” special symbols. Describe three of these special symbols.

R3.3.

Identify three categories of characters that are defined in Unicode but not in ASCII.

R3.4.

Distinguish the UTF-8 and UTF-16 encodings for Unicode.

Review R: Representing data: Solutions

R1.1.

There are 8,192 bits in a kilobyte:

8 bits × 1,024 bytes = 8,192 bits
byte KB KB
R1.2.

16 × 109

R1.3.

32 × 1012

R1.4.

8,000. (223 / 210 = 213 = 23 × 210 ≈ 8 × 103 = 8,000. We divide initially by 210 because that is how many bytes are in a kilobyte.)

R1.5.
a.101101(2)= 45(10)
b.1010101(2)= 85(10)
c.23(10)= 10111(2)
d.95(10)= 1011111(2)
R1.6.

Humans communicate much more easily with short strings, and hexadecimal numbers are 4 times shorter than binary numbers, so that is why they prefer hexadecimal over binary. However, we sometimes want to avoid decimal, since decimal numbers cannot be easily converted to binary representation, and often the binary representation is crucial to a program's meaning; by contrast, hexadecimal has a straightforward correspondence to binary.

R1.7.
a. 110110(2)=54(10)
b. 140(10)=10001100
c. E1EC7ED(16)= 1110 0001 1110 1100 0111 1110 1101(2)
R1.8.
a.1 010 101 010 101(2) = 12525(8)
b.10 1010 1010 1010(2) = 2AAA(16)
c.10 1101(2) = 2D(16)
d.560(8) = 101 110 000(2)
e.CAB(16) = 1100 1010 1011(2)
f.D15EA5ED(16) = 1101 0001 0101 1110 1010 0101 1110 1101(2)
R2.1.
a.10(10) 0000 1010
b.−60(10) 1100 0100
c.−104(10) 1001 1000
R2.2.
a.−1(10) 111 1111
b.−20(10) 110 1100
c.20(10) 001 0100
d.−300(10) 1110 1101 0100
R2.3.
a.110110−10(10)
b.01010121(10)
c.−12(10)110100
R2.4.
a.Sign-magnitude: 111 1111 represents −63(10)
b.Two's-complement: 100 0000 represents −64(10)
R3.1.

ASCII is a mapping to seven-bit values for the characters found on an English keyboard and special symbols.

R3.2.
  • The LF (linefeed) character is used to represent line breaks in a file. It is sometimes accompanied by a preceding CR (carriage return) character.
  • NUL (ASCII 0) is used by C to represent the end of a string.
  • BS represents a typed backspace
  • ESC represents a typed escape key
  • HT represents a tab character
  • BEL represents a sounded bell
  • FF represents a command to eject a page (or clear the screen)
R3.3.

There are many answers here, but some possibilities: accented characters for other European languages (like ñ, é, and ö), Chinese characters (Han alphabet), the Cherokee alphabet, the Greek alphabet, the Arabic alphabet, the Hebrew alphabet, Egyptian hieroglyphics, playing cards, emoticons, mathematical symbols, musical notes and symbols.

R3.4.

Both represent ways to encode Unicode code points into binary representation. UTF-16 works in two-byte blocks with all code points up to U+FFFF being encoded in precisely two bytes, But UTF-8 works in one-byte blocks with code points up to U+FFFF being encoded in one to three bytes; this allows UTF-8 to be backwards compatible with files represented simply with one ASCII character per byte.