home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / texts / txtfiles_misc / binary.txt < prev    next >
Text File  |  1996-03-27  |  7KB  |  109 lines

  1. The Binary Number System
  2. converted by: Unreal
  3.  
  4.     All digital computers are basically collections of switches. Each 
  5. switch has two possible positions: open, "0", or off; and closed, "1", or 
  6. on. The two positions form the basis of the binary (or two-valued: 0, 1) 
  7. number system. Otherwise, the computer uses numbers as we do in familiar 
  8. decimal system.
  9.  
  10. -= Binary Numbers =-----------------------------------------------------------
  11.     Any number can be represented in binary as well as in decimal 
  12. form. For example, the number 1,985 expressed in binary form is 
  13. 11111000001. As is the case with decimal numbers, we can interpret a
  14. binary number as the sum of a series of powers of the base number. For 
  15. example, in decimal notation:
  16.  
  17. (p = to the power of)
  18.     1,985 = 1 x 10p3 + 9 x 10p2 + 8 x 10p1 + 5 x 10p0
  19. that is,
  20.     1,985 = 1 x 1,000 + 9 x 100 + 8 x 10 + 5 x 1
  21. Similarly, in binary notation:
  22.     11111000001 = 1 x2p10 + 1 x 2p9 + 1 x 2p8 + 1 x 2p7 + 1 x 2p6 + 0 
  23.         x 2p5 + 0 x 2p4 + 0 x 2p3 + 0 x 2p2 + 0 x 2p1 + 1 x 2p0
  24. or, in decimal notation:
  25.     11111000001 = 1 x 1,024 + 1 x 512 + 1 x 256 + 1 x 128 + 1 + 64 +                        
  26.         0 x 32 + 0 x 16 + 0 x 8 + 0 x 2 + 1 x 1
  27.                                      
  28.     Numbers can be used to represent nonnumerical quantities, such as 
  29. letters of the alphabet and punctuation marks. A standard code is often 
  30. used to assign specific patterns of binary numbers to printable 
  31. characters.
  32.  
  33. -= Logic Circuits =-----------------------------------------------------------                                                        
  34.     Binary numbers can also be used to represent the results of 
  35. logical operations. For example, if 1 represents TRUE and 0 represents 
  36. FALSE, we can represent all logical functions (except "maybe") by 
  37. sequences of binary numbers. We can then arrange the circuits of a 
  38. computer to make logical tests on statements given to the machine. These 
  39. logic circuits enable the CPU (central processor unit) to react to an 
  40. incoming instruction or piece of data.                                   
  41.     For example, an important feature of the computer (and of the 
  42. human mind) is the ability to decide between two alternatives. Suppose the 
  43. computer must decide who in a group of people are at least 21 years of 
  44. age. The computer examines the item of data labeled "age" for each member 
  45. of the group. Each time it examines the age, a logic circuit in the CPU 
  46. compares the binary number for the age with the binary number for 21. If 
  47. the age number is equal to or greater than 21, the circuit produces a 1, 
  48. for TRUE. If the age number is less than 21, the circuit produces a 0.   
  49.     The type of circuit used for logical comparisons is called a gate 
  50. because the circuit acts to pass on 1's, like a gate in a fence, only for 
  51. the logical conditions for which it is set. there are two basic kinds of 
  52. gate: AND and OR, representing the two basic kinds of logical decision to 
  53. be made. In the simplest form, each gate has two inputs and one output. 
  54. An AND gate produces a 1 at its output only if both of its inputs are also 
  55. 1. An OR gate produces a 1 at its output if either or both of its inputs 
  56. are 1's. A third kind of gate, called an XOR gate (exclusive OR), produces 
  57. a 1 at its output only if one input but not the other is a 1. In other 
  58. words, and AND gate produces 0's unless both inputs are 1's; an OR gate  ;
  59. produces 0's only if both inputs are 0; an XOR gate demands one of each.
  60.     To see how this works, suppose a computer is in charge of a baking 
  61. a roast in a microwave oven. The owner of the oven programs it to stop 
  62. cooking the roast when either the preset time has elapsed or the 
  63. thermometer in the roast reads 140 degrees F. The logic gate used by the 
  64. computer in the oven for this task is an OR gate. At the start of the 
  65. cooking process, neither the timer output nor the thermometer output 
  66. satisfies the conditions set in the oven (timer output greater than or 
  67. equal to 140). Therefore , the OR gate will produce a 0 at its output,   
  68. since both inputs are 0. At some point one or both of the conditions will 
  69. be met and the OR gate will produce a 1. thereby shutting down the oven.
  70.     Now suppose the chef, knowing it is possible to get thermometer 
  71. reading that is too high if the thermometer is touching the bone in the 
  72. roast, sets the oven to stop cooking when the thermometer has at least 
  73. reached a certain point and the proper cooking time has elapsed. The 
  74. difference between this and the previous situation is that an AND gate is 
  75. used in the microwave computer; the gate produces the required 1 only when 
  76. both the temperature has reached 140 degrees F. and the roast has cooked 
  77. for 30 minutes. All the complex logical operations of much more 
  78. sophisticated computers can be reduced to combinations of logic-gate 
  79. operations much like those described.
  80. ______________________________________________________________________________
  81.  
  82. Logic Gate Illustration:
  83.                          *    A
  84.        *   A   *   B    ┌───┐                ┌───┘   *───┐   ┌───┐
  85.   ┌────┘   *───┘   *────│   │ <- Bell  ┌─────│   *    B  │───│   │
  86.   │                     └───┘          │     └───┘   *───┘   └───┘
  87.  ─┼─                      │           ─┼─                      │
  88. ┌───┐ <- Battery          │          ┌─┴─┐                     │
  89. └───┘                     │          └───┘                     │
  90.  ─┼─                      │           ─┼─                      │
  91.   └───────────────────────┘ (a)        └───────────────────────┘ (b)
  92.  
  93.                               A
  94.        A       B    ┌───┐                ┌───────*───┐   ┌───┐
  95.   ┌────────*───────*────│   │          ┌─────│        B  │───│   │
  96.   │                     └───┘          │     └───────*───┘   └───┘
  97.  ─┼─                      │           ─┼─                      │
  98. ┌───┐                     │          ┌─┴─┐                     │
  99. └───┘                     │          └───┘                     │
  100.  ─┼─                      │           ─┼─                      │
  101.   └───────────────────────┘ (c)        └───────────────────────┘ (d)
  102.                                      
  103. Logic Gates can be though of as doorbell circuits: (a) an AND gate, where     
  104. the two switches A and B are connected in series and both must be close to 
  105. the ring bell; (b) an OR gate, where the two switches are connected in 
  106. parallel and either must be closed to ring the bell; (c) a NAND (not AND) 
  107. gate, where both switches must be open for the bell to ring; (d) a NOR 
  108. (Not OR) gate, where either switch must be open for the bell to ring.
  109.