home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / texts / txtfiles_misc / binarymath.text < prev    next >
Text File  |  1995-07-10  |  7KB  |  188 lines

  1. #DATA $NAME "An Introduction to Boolean Arithmetic" / $AUTHOR "Light Ray" / $VERSION 001 / $DATE  950709 / $TYPE  { TEXT ASCII CRLF } #DATA
  2.  
  3.           ********************************************************
  4.           *                                                      *
  5.           *                    An Introduction To                *               
  6.           *                                                      *
  7.           *                     Boolean Arithmetic               *
  8.           *                      aka Binary Math                 *
  9.           *                                                      *
  10.           *                           by                         *
  11.           *                                                      *
  12.           *                        Light Ray                     *
  13.           *                                                      *
  14.           ********************************************************
  15.  
  16.   NOTE: This refers to "binary arithmetic" as in arithmetic involving
  17.   the manipulation of binary bits, not necessarily arithmetic involving
  18.   two operands.
  19.  
  20.   PREREQUISITE: NumberBases.* / NUMBASES.*
  21.  
  22.   The following operations will be summarized in this 
  23.   document:  NOT, AND, NAND, OR, NOR, and XOR.
  24.  
  25.   //===================\\
  26.   || SIMPLE OPERATIONS ||
  27.   \\===================//
  28.  
  29.   The NOT, AND, OR, and XOR operations are "atomic."  That is, these are
  30.   the simplest operations and any other operation can be "built" using
  31.   them.
  32.  
  33.   +-------------------+
  34.   | The NOT Operation |
  35.   +-------------------+
  36.  
  37.   NOT is sometimes known as the "Inverse" operation.
  38.  
  39.   NOT simply reverses the state of all bits.  A one becomes a zero and
  40.   a zero becomes a one.
  41.  
  42.   The expression "NOT A" is written as "A" with an overscore. (an overscore
  43.   is a horizontal line above the letter).
  44.  
  45.        +--------------+--------------+
  46.        | Input (A)    | Output (B)   |         _
  47.        +--------------+--------------+     B = A 
  48.        |     0        |     1        |
  49.        |     1        |     0        |
  50.        +--------------+--------------+
  51.  
  52.   The converse of a not operator is true.  If A = NOT B, then B = NOT A.
  53.  
  54.   
  55.   +-------------------+
  56.   | The AND Operation |
  57.   +-------------------+
  58.  
  59.   The and operation is a binary operator.  It takes two parameters, usually
  60.   in the form "a AND b".
  61.  
  62.   AND results in 1 only when both operands are 1, otherwise it results in
  63.   zero.
  64.  
  65.   AND is sometimes written as a dot or multiplication sign.
  66.  
  67.   Here is the truth table for C = A AND B
  68.  
  69.        +--------------+--------------+--------------+
  70.        | Input (A)    | Input (B)    | Output (C)   |
  71.        +--------------+--------------+--------------+  
  72.        |     0        |     0        |     0        |  C = A AND B
  73.        |     1        |     0        |     0        |  C = A * B
  74.        |     0        |     1        |     0        |
  75.        |     1        |     1        |     1        |
  76.        +--------------+--------------+--------------+
  77.  
  78.   +-------------------+
  79.   | The OR Operation  |
  80.   +-------------------+
  81.  
  82.   The OR operation is a binary operator.  It takes two parameters, usually
  83.   in the form "a OR b".
  84.  
  85.   OR results in 1 when at least one input is 1.  This can be rephased to
  86.   say that the output is 0 only when both inputs are zero, otherwise it
  87.   is one.
  88.  
  89.   OR is alternatively written as a plus sign.
  90.  
  91.   Here is the truth table for C = A OR B
  92.  
  93.        +--------------+--------------+--------------+
  94.        | Input (A)    | Input (B)    | Output (C)   |
  95.        +--------------+--------------+--------------+  
  96.        |     0        |     0        |     0        |  C = A OR B
  97.        |     1        |     0        |     1        |  C = A + B
  98.        |     0        |     1        |     1        |
  99.        |     1        |     1        |     1        |
  100.        +--------------+--------------+--------------+
  101.  
  102.   +-------------------+
  103.   | The XOR Operation |
  104.   +-------------------+
  105.  
  106.   XOR is a binary operation and is a derrivative of the OR operator.
  107.   
  108.   XOR stands for "EXCLUSIVE OR", meaning that it results in ONE if and
  109.   only if either operand is one, but results in zero of neither or both
  110.   operands are one.
  111.  
  112.   XOR is alternatively written as a plus enclosed by a circle, written
  113.   in ASCII as a plus in parenthesis.
  114.  
  115.        +--------------+--------------+--------------+
  116.        | Input (A)    | Input (B)    | Output (C)   |
  117.        +--------------+--------------+--------------+  
  118.        |     0        |     0        |     0        |  C = A XOR B
  119.        |     1        |     0        |     1        |  C = A (+) B
  120.        |     0        |     1        |     1        |
  121.        |     1        |     1        |     0        |
  122.        +--------------+--------------+--------------+
  123.  
  124.   //===================\\
  125.   || COMLEX OPERATIONS ||
  126.   \\===================//
  127.  
  128.   These operations may be built using the other operations.
  129.  
  130.  
  131.   +--------------------+
  132.   | The NOR Operation  |
  133.   +--------------------+
  134.  
  135.    A NOR B is one only when (A==0) and (B==0).
  136.  
  137.    [ "==" is read "is".  (A==B) is true (1) when A equals B, otherwise
  138.     it is false (0). ]
  139.  
  140.    if    C = A NOR B
  141.    then  C = NOT (A OR B) 
  142.  
  143.    C = NOT (A OR B) is alternatively written as A+B with an overscore:
  144.        _______
  145.    C = (A + B)
  146.    
  147.        +--------------+--------------+--------------+
  148.        | Input (A)    | Input (B)    | Output (C)   |  
  149.        +--------------+--------------+--------------+  
  150.        |     0        |     0        |     1        |  C = NOT (A + B)
  151.        |     1        |     0        |     0        |      _______
  152.        |     0        |     1        |     0        |  C = (A + B)
  153.        |     1        |     1        |     0        |
  154.        +--------------+--------------+--------------+  C = (A==0) AND (B==0)
  155.  
  156.   +---------------------+
  157.   | The NAND Operation  |
  158.   +---------------------+
  159.  
  160.    if   C = A NAND B
  161.    then C = NOT (A AND B)
  162.  
  163.        +--------------+--------------+--------------+
  164.        | Input (A)    | Input (B)    | Output (C)   |  
  165.        +--------------+--------------+--------------+  
  166.        |     0        |     0        |     1        |  C = NOT (A * B)
  167.        |     1        |     0        |     1        |      _______
  168.        |     0        |     1        |     1        |  C = (A * B)
  169.        |     1        |     1        |     0        |
  170.        +--------------+--------------+--------------+  C = NOT ((A==1) AND (B==1))
  171.  
  172.  
  173.   ---------------------------------
  174.    END
  175.   ---------------------------------
  176.  
  177.   This was typed and editted by Light Ray at the Digital Forest BBS,
  178.   which may be reached at +1 (714) 586-6142.  It is located in 
  179.   Mission Viejo, California, United States of America.  This document
  180.   is based on Explorer Post 340 "lab notes" by "rlh" dated 5/10/95.
  181.   Please send any comments, suggestions, compaints, or addittions to
  182.   me at dr261@cleveland.freenet.edu, even if all you say is "I read
  183.   your file."  I may also be reached at 1:103/925, 66:714/10, or
  184.   50:100/505.
  185.  
  186.   Light Ray
  187.                 
  188.