calc
Perform arithmetic calculations
TLDR
Start calc in interactive mode
Perform a calculation in non-interactive mode
Don't format the output (for use with [p]ipes)
Perform a calculation and then switch to [i]nteractive mode
Start calc in a specific permission [m]ode (0 to 7, defaults to 7)
View an introduction to calc
View an overview of calc
Open the calc manual
SYNOPSIS
calc [options] [file]
PARAMETERS
-b base
Set the output base (2-36). Defaults to 10.
-c
Start with a cleared calculator state (no saved variables or functions).
-d digits
Set the number of decimal digits to use for calculations.
-e expression
Evaluate the given expression and exit.
-f file
Execute commands from the specified file.
-h
Display help message.
-i
Ignore case for variable names.
-l
List built-in functions.
-p
Print precision and base settings.
-q
Quiet mode: suppresses prompts and banner.
-r base
Set the input base (2-36). Defaults to 10.
-s
Silent mode: suppresses all output (except errors).
-v
Display version information.
DESCRIPTION
The calc command is an interactive arbitrary precision calculator. It allows users to perform complex mathematical calculations with a higher degree of accuracy than standard calculators or scripting languages. It supports a wide range of mathematical functions, including trigonometric functions, logarithms, exponential functions, and user-defined functions.
calc's primary advantage lies in its ability to handle numbers with a very large number of digits, overcoming the limitations of floating-point arithmetic. Users can set the desired precision (number of significant digits) to meet specific requirements. It allows you to perform complex arithmetic without the risk of integer overflow issues.
The calculator operates in interactive mode, where users enter expressions, and the results are displayed immediately. Additionally, calc can be used in batch mode, reading commands from a file. It is suitable for scenarios where precision is paramount, such as scientific research, financial modeling, or cryptographic operations.
CAVEATS
Error messages are displayed using stderr, not stdout.
Complex numbers and matrix operations are not supported by default.
FUNCTIONS
calc supports many built-in functions. See manual page for details.
Examples: sin(x), cos(x), log(x), exp(x), sqrt(x), etc.
Users can also define their own functions.
VARIABLES
Variables can be used to store intermediate results for later use.
Example: x = 10; y = x * 2; print y;
INTERACTIVE MODE
In interactive mode, calc displays a prompt where you can enter expressions. The results are printed after each evaluation. To exit interactive mode, type 'quit' or 'exit'.
HISTORY
calc has evolved over time as a powerful arbitrary precision calculator, with updates including bug fixes, feature enhancements (like trigonometric functions, logarithms, and user-defined functions) and optimization in arithmetic calculation. The project aims to deliver a practical CLI tool to perform arithmetics in a controlled manner.