alert_red.gifupdated.gifLAST UPDATE: 10/8/06; 10/17/06; 10/10/07alert_red.gif

LEARNING MODULE IIIA
REPRESENTATIONS OF NUMBERS AND TEXT

redstar.gifTPQ 1: The in-class presentation of this topic begins (without this Learning Module) with the question: give a complete definition of the number 11.

    Humans do mathematics with the  base 10 number system ("decimal system") and they write languages using various alphanumeric codes (symbols consisting of letters, numbers, and punctuation marks).  Digital computers, however, perform math using the base 2 number system (binary system) and represent alphanumerics as binary codes.  Therefore, it is important for humans to understand these binary systems in order to understand how computers function. Because this is an introductory course we will not delve to deeply into the details of binary numbers and codes so our limited goals of this Learning Module IIIA are to help the student learn how to:

  1. understand the straightforward basics of number systems, in general,
  2. count in any number system,
  3. convert decimal numbers to/from binary numbers, and
  4. translate English to/from ASCII (American Standard Code for Information Interchange)
redstar.gifNOTE:  If you are an independent learner (not attending the on-campus classes), it is especially important to read the study guide for this LM.  Even though it is virtually impossible to simulate the interactive in-class presentation on this Web site, I do try.  However, I need your help, so read the study guide to try to understand what I am trying to do.  (I'd appreciate your feedback on how to imporve this simulations of the class environment.)

TPQ 2: Rewrite the preceding objectives in terms of personal accomplishments to be attained after finishing the study of this learning module.

The sequence of presentation of the learning module is:

  1. COMPUTER CODE BASICS
  2. COMPARISONS OF NUMBER REPRESENTATIONS
  3. UNDERSTANDING THE DECIMAL NUMBER SYSTEM
  4. APPLYING THE REPRESENTATION IDEA TO BASE 2
  5. SUMMARY OF THE LEARNING MODULE 
  6. ILLUSTRATIONS:
The approach used, in the following presentation, is not to "teach" you anything new, but to help you understand the "decimal system" system you use every day and to generalize that understanding to any other number systemIf you truly understand any number system, you understand all number systems.  Therefore, you will not need to crowd your mind with more useless detail that you will soon forget.  If you understand the base 10 number system, you will always be able to figure out any number system, including the binary system native to digital computers.

NOTE: This only introduces the student to number systems; the arithmetic of these numbers is left to other courses.  The goals are to be accomplished, in interactive sessions, by drawing analogies between the decimal number system and other number systems.

SAQ 1: What code (could also be called a "protocol") do we use to communicate in class?

1 COMPUTER CODE BASICS:

  1. The Elements of Binary Codes:
    1. The "bit", short for  binary digit is the smallest unit of computer data.  Bits, the foundation of the binary number system, can have a value of only 1 or 0.   Bits are perfectly suited to represent binary data such as on/off (transistor states), true/false (logic states), etc.  Therefore, binary numbers are a "natural" for such systems.
    2. The "byte" is any sequence of eight bits. It is the smallest unit of human data because ASCII and EBCDIC (the two primary binary codes for representing keyboard characters; see section 1.C, below.) are eight bit codes.
    3. The "word" is a unique sequence of bits that is characteristic of a particular computer processor.  This specifies the number of bits that a given computer can handle at one time (one clock cycle).  The word in the first PCs were 8 bits, but now can be 16, 32, 64, bits; these will keep going up as technology improves.
    4. ______(1) is a sequence of four bits. (Guess what this name is. Hint: it demonstrates that computer scientists have a sense of humor.)
SAQ 2: How many (a) bits, (b) bytes, and (c) words are contained in a register of a "16 bit computer" that reads: 0101000011011111?
  1. Number systems (numeric codes) associated with computers:
    1. In order to facilitate calculation and communication of numbers (between humans) various numeric formats (codes) have been devised to represent numbers.  The most efficient codes have a base, e.g. base 10 (decimal), base two (binary), etc.; large numbers are expressed in terms of powers of the base; see sections 2, 3, and 4.  A trailing subscript is used to indicate the base used to represent a number,  e.g. 1110 means the number is expressed in the base ten number system; 112 means base 2.  (Note that 1110 and 112 are very different numbers!)
    2. The most common number system used in computer science are:
      1. A binary number is any number expressed in pure binary form; this means it is represented only two symbols. (Bits are the mathematical form, but any two-state system can represent a binary number.)  Perhaps unfortunately, the metric prefixes "kilo", "mega", "giga", "tera" are used to represent powers of 2 in the binary system, but a "kilobyte" is 210 (1024) bytes, not 1000 bytes!  Thus when used with computer data the following terms are always larger than their decimal equivalent.
        • kilo is 210 (1,024)
        • mega is 220 (1,048,576)
        • giga is 230 (1,073,741,284)
        • tera is 240 (1,099,511,627,776)
        Note that most people assumes kilo... is "about" a thousand, mega... is "about" a million, etc.  The actual numbers are always higher, but for these four prefixes not off by more than 10%.
      2. Octal is a base eight number system where all numbers are represented by combinations of the digits 0-7 and powers of 8.
      3. Hexadecimal ("hex") is the base 16 numbers system; all numbers are represented by combinations of the digits 0-9 and ______________________(2) and powers of 16.
  1. Alphanumeric codes associated with computers:
    1. ASCII (American Standard Code for Information Interchange) is the most common binary code used to represent text in computers.   In an ASCII file, each alphabetic, numeric, or special character is represented with a 7-bit code (a string of seven 0s or 1s); this allows 128 (27) possible characters to be specified.  UNIX and DOS-based operating systems (except for Windows NT) use ASCII for text files. ASCII was developed by the American National Standards Institute (ANSI).  (See Figure A-1 in Shelly & Cashman for a comparison of 8-bit ASCII and EBCDIC, an equivalent binary code used in IBM mainframes.  Also see Table IIIA-1 for alternate codes for decimal and hexadecimal.)
      1. Extended ASCII specifies an 8-bit (one ______(3)) non-standard character set by defining characters for the binary codes 128 -255, above the 0-127 standard ASCII codes. Extended ASCII symbols are different for each font. The standard font in DOS uses extended ASCII for foreign language letters as well as characters that make up simple charts and diagrams. (See the Extended ASCII chart in Table IIIA-2.)
        1. Control characters (which facilitate keyboard use) make up the first 32 ASCII values (010 to 3110) as well as the last (the delete key, 12710).
        2. Printable characters are represented by 3210 to 12610.
      2. The ANSI-standard character set (sometimes carelessly called "ANSI") is a standard8-bit code that defines all 256 characters. The first 128 are ASCII, and the second 128 contain math and foreign language symbols, which are different than those on the PC. This is used in Microsoft Windows.
    2. Unicode (the Unicode Worldwide Character Standard) is a 16-bit encoding system for "the interchange, processing, and display of the written texts of the diverse languages of the modern world."  These characters cover the principal written languages of the world. Additional work is underway to add the few modern languages not yet included. For more information see the Unicode Home Page at http://www.unicode.org/. which says: "Unicode provides a unique number for every character, no matter what the platform, no matter what the program, no matter what the language". (redstar.gifSee the superb article on unicode in Wikipedia; in particular note how even musical notes are being represented!)
    3. Conversion programs allow files to be changed from one code to another. 
    4. For details about alphanumeric codes see Wikipedia:
      1. ASCII,
      2. EBCDIC, abd
      3. Unicode.
    redstar.gifYou should now be able to have a shot at answering questions 5 of the DATA REPRESENTATION ASSIGNMENT.
TPQ 3: (a) When ASCII was developed, there were other binary codes available, e.g.  the ________ code used for telegraphs.  (b) Why do you suppose a new code was developed instead of using this existing international standard.
SAQ 3: Show that an 8-bit code can specify a maximum of 256 symbols and a 16-bit code can specify 65,536. (You may need to study the rest of this learning module to answer this.)

2. COMPARISON OF NUMBER REPRESENTATIONS:

        There are many ways to represent a given number.  The following table contains a cross-section of these representations.  Fill in the blanks in order to get a feeling for the similarities between the different bases.  Note that all of these are human representations of the concepts of the numbers.  Humans need these representations to communicate them to others and to easily perform mathematical operations with them.  However, it is important to remember that they mean nothing to someone who does not know the symbolism!  (See the TPQs at the end of the table.)
 

ENGLISH 
ROMAN NUM.
DECIMAL
BINARY
BASE 3
BASE 4
OCTAL
HEXADECIMAL
zero   0 0 0 0 0 0
one I 1 1 1 1 1 1
two II 2 10 2     2
  III 3 11 10     3
  IV 4 100 11  
 
4
  V 5 101 12     5
  VI 6 110 20     6
  VII 7 111      
7
 
VIII
8
1000
     
8
 
IX
9
1001
100
   
9
 
X
10
1010
       
 
XI
11
1011
       
 
XII
12
         
 
XIII
13
         
 
XIV
14
         
 
XV
15
 
120
     
 
XVI
16
         
 
XVII
17
         
 
XVIII
18
10010
200
 102
 22
12

TPQ 4: (a) The Roman numeral system is cumbersome and extremely clumsy to use. (Can you imagine multiplying XLIV times LXXII?) Explain the origin of this weakness.  (b) Strictly speaking, the year 2000 will NOT be the beginning of the new millennium.  Explain the reason for this surprising, widely misunderstood fact.
TPQ 5: Considering the interesting symmetry in the repetition of the digits when one counts in any number system answer the following questions  (a) When does the number of digits increase when counting (i.e. what numbers do we represent by a 1 followed by a string of zeros) in a given number system.  (b) What is the relationship between the number of these zeros and the base of the number system.  (c) What is the relationship between the zeros on the right (regardless of whether the first nonzero is a one or not) and the base of the number system?
TPQ 6: What (a) movie character and (b) TV character probably uses a base 8 number system?

redstar.gifYou should now be able to have a shot at answering questions 1 of the DATA REPRESENTATION ASSIGNMENT.

3. UNDERSTANDING THE DECIMAL NUMBER SYSTEM:

  1. ILLUSTRATION: Breakdown of the number 702.49 shows that this representation is a shorthand for:
    1. 7 x 102  = 700
    2. 0 x 101  =    0
    3. 2 x 100  =    2
    4. 4 x 10-1  =      .4
    5. 9 x 10-2  =      .09
                              702.49 = the sum of ________(4) of the _____________________(5) of 10 (the base).
     
  2. Basic idea of the of the base 10 number system (implied by the preceding illustration):
    1. We represent any number by the string of digits that are the multiples of the corresponding power of ten, i.e.
        ...103  102  101  100  .  10-1 10-2
        ...___  ___  ___  ___  .  ___   ___
    1. Common sense indicated that this has nothing to do with the actual base we are using; therefore, the same idea should apply to any number system.
4.  APPLYING THE REPRESENTATION IDEA TO BASE 2:
  1. Representation of Binary numbers has the format:

  2.  
        ...  23    22    21    20  .  2-1   2-2
        ...___  ___  ___  ___  .  ___  ___
    where, now, the blanks can contain only _______(6).
  3. Conversion from Binary to Decimal (ignoring fractions, which are straightforward but irrelevant):
    1. Illustrative example: conversion of the binary number 1011 to its decimal equivalent.
      1011:  1 x 1 =   1
                1 x 2 =   2
                0 x 4 =   0
                1 x 8 =   8
                sum  = 1110  implies that 101112 = 1110.
       
    1. The "Rule for converting binary numbers to decimal numbers", implied by these examples is (loosely stated):
      "To determine the decimal equivalent of a binary number,
      1. multiply ____________(7) by the _______________________________(8);
      2. the decimal value = _________________________________________(9).
TPQ 7: Generalize the preceding rule so that it would cover any number system.
TPQ 8: If we multiply to convert binary to decimal, what do you expect we need to do to convert decimal to binary?
TPQ 9: What is a QUICK way to evaluate a binary number that is all ones, e.g. 111111?

redstar.gifYou should now be able to have a shot at answering questions 2 and 3 of the DATA REPRESENTATION ASSIGNMENT.

  1. Conversion from Decimal to Binary (ignoring fractions, which are straightforward but irrelevant):
    1. Direct approach:  Note that when we say, in words, a decimal number we read left to right and simply say the power of the corresponding power of ten, i.e. we systematically specify how many of each power of ten (highest to lowest) are "in" the number we are reading.  Common sense the implies that to find the binary equivalent of a number, we need to determine how many of each power of two are needed to completely specify the number.  For example, to find the binary equivalent of 2310:
      1. First find the highest power of two that is "in" 2310. (Note that this is exactly what we do, automatically, when we read a number, e.g. when we read 3,456, we first say "three thousand".)  The highest power of two in  is 1610 or 25.
      2. Successively determine if each of the lower powers of two are "in" the remainder of the number  and write 1 if it is 0 if not (not surprisingly, left to right).  Note that in the following example these are rather clumsy text representations of long division.
                              1
          16)23       gives us  1 _ _ _ _
             16
              7


        (Note that we reserved spaces for all bits.)  Then we continue by dividing the remainder by the next highest power of two, and so on i.e.
         

              1
            8)7       gives us  1 0 _ _ _
              0
              7

              1
            4)7       gives us  1 0 1 _ _
              4
              3

              1
            2)3       gives us  1 0 1 1 _
              2
              1

              1
            1)1       gives us  1 0 1 1 1
              1
              0
           

        This simply says that there is one 16, one 8, one 4, one 2 and one 1 in 2310, or  2310= 101112.
SAQ 4: Generalize the rules for converting decimal to binary that cover the conversion of decimal numbers to an equivalent in any base.
    1.  Indirect approach: It is interesting to note that the same conversion can be accomplished with an almost inverse approach.  If one divides the decimal number successively by 2 (instead of powers of two), writes down the remainder (instead of each quotient) right to left (instead of left to right) the correct conversion is obtained.  Since this is less intuitive, we will not pursue it.
redstar.gifYou should now be able to have a shot at answering questions 4 of the DATA REPRESENTATION ASSIGNMENT.
alert_red.gifredstar.gifTPQ 10: Mathematics using binary numbers is beyone the scope of this presentation; however, it will be enlightening to answer the following question.  What is the sum of 1112 and 112? (HINT: Remember our primary guideline, number systems all work alike - the only difference is the base.  Therefore, find the base 10 equivalent of the two numbers and add them; then do the same in base 2 and check your answers.)

5. SUMMARY OF THE LEARNING MODULE:

  1. Computer Code basics:
    1. Binary code consists of collections of bits (binary digits) which can be grouped in bytes (eight bits) and words (size depends on the CPU).
    2. Numbers systems associated with computers are all based on powers of two.  These include binary (base 2), octal (base 8), and hexidecimal (base 16, often called "hex" for short).
      1. A trailing subscript is used to indicate the base used to represent a number.
      2. Metric prefixes, e.g. kilobits, kilobytes, etc., are used to abbreviate large binary numbers, BUT these represent powers of 2 NOT powers of 10, so a kilobit is 1024 bits, NOT 1000 bits!
    3. Alphanumeric codes associated with computers govern the conversion of text to binary codes and visa versa.
      1. ASCII is the defacto standard seven bit binary code used to represent text in computers.  It has more commonly used, nonstandard extensions to eight bits
  2. The table illustrates the different base representations of the numbers between zero and eighteen; the blanks motivate an interactive way to understand the similarities of these representations.
  3. The decimal number system represents real world numbers with ten symbols (0 through 9), which, when ordered from left to right, specify the number of decreasing powers of 10, i.e.10n to 100.
  4. The binary number system:
    1. The binary number system represents real world numbers with two symbols (0 and 1), which, when ordered from left to right, specify the number of decreasing powers of 2, i.e. 2n to 20Compare this to item 3, above.
    2. To convert the representation of a number from binary to decimal, multiply each bit by the corresponding power of two (in base 10) and add up the products.
    3. To convert the representation of a number from decimal to binary
      1. divide the number by the highest power of 2 that can divide into the number, then...
      2. divide each successive remainder by the next highest power of 2, and
      3. write out the quotients from left to right.
ASCII AND EXTENDED ASCII CHARACTER SETS
TABLE IIIA-1
A table of printable characters is given in Wikipedia.
TABLE IIIA-1