Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

10.0;dcalc (desk_calculator), revision 1.0, 88/01/21
dcalc (desk_calculator) -- Evaluate logical and arithmetic expressions.
usage:  dcalc [-h]  [pathname...]



DESCRIPTION
     dcalc mimics the features of a desk calculator, evaluating both logical
     and arithmetic expressions.


ARGUMENTS
     pathname (optional)
                    Specify input file containing expressions to be evaluated,
                    one expression per line.

                    Default if omitted:  read standard input; stop with EOF
                    signal (usually CTRL/D or CTRL/Z)

OPTIONS
     If no options are specified, all operations are decimal-based.

     -h             Specify hexadecimal operations.


Expressions
     Input  expressions can be simple arithmetic expressions or variable
     assignment expressions.  dcalc writes the value of each evaluated
     expression on  standard output.    Variables hold temporary values, which
     dcalc does not automatically write.

     Expressions may include any  of  the  operators  listed below  in  order
     of precedence:

     1.  +  -       Unary plus and negation operators.  These may appear only
                    at the start of an expression or within parentheses.

     2.  << >>      Logical left and right shift

     3.  **         Exponentiation

     4.  *  /  %    Multiply, divide, modulo (remainder)

     5.  +  -       Add, subtract

     6.  ==         Equal to

       !=           Not equal to

       >            Greater than

       >=           Greater than or equal to

       <            Less than

       <=           Less than or equal to

     7.  !          Unary logical not

     8.  |          Logical or

       &            Logical and

       ^            Logical xor

     Relational  operators  return  the  value  1  for true and 0 for false.
     dcalc performs operations in double precision floating  point,  except
     for  logical operators listed as items 2 and 8 above, which use 32-bit
     integers.

Variables
     Expressions  may  include  previously  declared variables.  Use this
     format to declare a variable:  name = expression

     +    A variable name must begin with a letter  and  may  consist  of  any
          combination of letters and digits.

     +    dcalc  does not automatically print replacement expressions, because
          they usually contain temporary values.


Radix Control
     You can change the default base for input or output using ibase  (input
     base) and obase (output base) statements.  For example,

     ibase = 2

     obase = 16

     causes dcalc to interpret input in binary and print results in
     hexadecimal.

     To  set  an individual number's radix, precede it with the desired radix
     and a pound sign.  For example,

     16#100

     specifies the hexadecimal number 100 (equals 256 in decimal).

EXAMPLES
     Your input:         dcalc output:


      10 + (-64 / 2**4)       6


     temp = 2#101
     temp == 5           1 (true)


     ibase = 16
     obase = 2
     11 + 28             111001
     1a + 0f             101001

     Note that when you type a hexadecimal number that begins with a letter,
     you must precede it with a zero.

     ibase = 16
     numa = 100
     numb = 100
     numa + numb         512

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026