Calc Usage


  • A brief help message which includes the list of default constants and functions is printed by 'calc -h'

  • Calc works in two modes, command-line and standard input. In the command line mode, you supply the expression as the command-line argument. This expression is evaluated and the result is printed. For example:
    % calc  10mp/(mp+me)
          
    In the standard input mode, you call calc without an argument, and then type the statements. For example
    % calc
    x=5
    y=2x-4
    5x-3y
    y**2
    x
    z=sin(x)
    z
    ^D
          
    When trying this example, notice that only statements that don't contain an assignment (the '=' sign) get printed
  • Private constants and functions may be declared by the user. Put the Perl code into a file and point the environment variable CALCRC to this file. Your code will be executed right after the default constants and functions are declared (so you can overwrite them).
  • You can additional control the script behavior by two enviroment variables:
    CALCDEBUG if set and non-zero, tells the script to print the expression that gets evaluated. So you are able to control how the script interprets your expressions
    CALCFORMAT overwrites a default format for printing the values, "%g"