Programming and Graphics

(Kiana) #1

1.2 The binary system 9


According to the American Standard Code for Information Interchange
convention (ASCII), 128 characters are represented by numerical values in the
range 0–127, as shown in Appendix D. Thus, seven bits are required to describe
the standard set of ASCII characters.


As an example, we consider the familiar equation

1+1=2. (21)

Referring to Appendix D, we find the ASCII representation:


49 43 49 61 50 (22)

which can be readily converted into a binary string and stored in a file or
transmitted to a device.


The extended ASCII character set (ECS) includes 128 additional charac-
ters encoded by integers in the range 128–254. The extended set includes Greek
and other European letters, various mathematical symbols, musical notes and
sounds. Eight bits (one byte) are required to describe each member of the
standard and extended ASCII character set.


An ASCII file contains bits corresponding to integers encoding ASCII
characters. An ASCII file should be contrasted with a binary file which does
not necessarily encode ASCII characters. An ASCII file can be viewed on the
screen, whereas a binary file can be interpreted by only an intended device.


Problems


1.2.1.Consider a binary string, such as 11010...0011, and its complement aris-
ing by flipping the bits, 00101...1100, encoding two integers. What is the
sum of these integers?


1.2.2.Compute the decimal equivalent of the binary number 101.101.


1.2.3.Compute the decimal equivalent of the binary number 0.11111..., where
the ones continue to infinity.


1.2.4.What is the binary number of Mother Teresa’s birth-year?


1.2.5.Compute the binary number of the decimal number 10.1.


1.2.6.The size of an ASCII file containing a document is 328 Kbytes. If each
ASCII character is an encoded as an one-byte word, how may characters
does the document hold? If the file holds a chapter of a book, how many
pages does the chapter have?

Free download pdf