Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ (1) — Plan9 3rd Edition (Vita Nuova)

Media Vault

Software Library

Restoration Projects

Artifacts Sought

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 output.  It is a command line interface to a ­TclLib calculator 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 decimal. 

Expressions are formed using the following C-like operators and predefined functions, shown in order of decreasing priority:

­- + ! ~
unary: negate, plus (no-op); logical not and one’s complement (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

­|| logical or

a?b:c conditional: if ­a is non-zero, the result is b, otherwise ­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

Plan 9  —  May 26, 2000

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