MATHCALC(1)                                           MATHCALC(1)
     NAME
          mathcalc - interface to a TclLib calculator module
     SYNOPSIS
          mathcalc
     DESCRIPTION
          Mathcalc reads simple expressions from the standard input,
          evaluates them, and prints the results on the standard out-
          put.  It is a command line interface to a `TclLib' calcula-
          tor module.  It prompts the user (`calc%') for each line,
          and exits on end-of-file or on reading a line containing
          `quit'.
          Values are either integer or floating-point constants.  A
          floating-point constant has a decimal point, an exponent, or
          both.  Integer constants are taken as hexadecimal if they
          start 0x, octal  if they start with 0, and otherwise deci-
          mal.
          Expressions are formed using the following C-like operators
          and predefined functions, shown in order of decreasing pri-
          ority:
          - + ! ~
               unary: negate, plus (no-op); logical not and one's com-
               plement (integers only)
          * / %
               multiply and divide, integer remainder
          + -  add, subtract
          << >>
               left shift, right shift (integers only)
          < <= >= >
               relational operators
          == !=
               equality, inequality
          &    bit-wise and (integer only)
          ^    bit-wise exclusive-OR (integer only)
          |    bit-wise or (integer only)
          &&   logical and
     Page 1                       Plan 9            (printed 10/31/25)
     MATHCALC(1)                                           MATHCALC(1)
          ||   logical or
          a?b:c
               conditional: if a is non-zero, the result is b, other-
               wise c
          Mathcalc provides the following mathematical functions:
               abs    ceil   fmod   sin
               acos   cos    hypot  sinh
               asin   cosh   log    sqrt
               atan   exp    log10  tan
               atan2  floor  pow    tanh
          See math-elem(2) for the usual definitions.
     SOURCE
          /appl/cmd/mathcalc.b
          /appl/lib/tcl_calc.b
     DIAGNOSTICS
          ARRG!   bad constant syntax
          Error!  bad expression syntax, or any other error
     Page 2                       Plan 9            (printed 10/31/25)