LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

calc

Arbitrary precision calculator

TLDR

Calculate expression
$ calc ["2 + 2"]
copy
Interactive mode
$ calc
copy
Define variables
$ calc ["x = 5; y = 3; x * y"]
copy
Use functions
$ calc ["sqrt(16)"]
copy

SYNOPSIS

calc [options] [expression]

DESCRIPTION

calc is an arbitrary precision calculator. It provides interactive calculation and scripting with support for complex arithmetic, trigonometry, statistics, and user-defined functions.The tool offers more features than bc while maintaining ease of use.

PARAMETERS

-c

Continue after errors
-d
Disable readline editing
-p
Pipe mode (no prompts)
-q
Quiet mode (no startup message)
-s
Enforce strict mode

FEATURES

- Arbitrary precision arithmetic- Complex numbers- Trigonometric functions- Statistical functions- User-defined functions- Variable assignment- Matrix operations- Fractions and rationals

FUNCTIONS

Arithmetic:- sqrt(x) - Square root- abs(x) - Absolute value- gcd(a,b) - Greatest common divisorTrigonometry:- sin(x), cos(x), tan(x)- asin(x), acos(x), atan(x)Other:- ln(x) - Natural log- exp(x) - Exponential- rand() - Random number

WORKFLOW

$ # Simple calculation
calc "2^100"

# Interactive mode
calc
> x = 5
> y = 10
> x * y + 3

# Script file
calc -f script.cal

# One-liner with precision
calc "pi(100)"  # Pi with 100 digits
copy

VARIABLES

$ > epsilon(1e-10)  # Set precision
> x = 5
> y = x^2 + 3*x + 1
copy

INSTALL

sudo apt install calc
copy
sudo dnf install calc
copy
sudo pacman -S calc
copy
sudo zypper install calc
copy
brew install calc
copy
nix profile install nixpkgs#calc
copy

CAVEATS

Different syntax than bc. Less commonly installed. Some functions require understanding of calc's type system. Error messages can be cryptic. Large computations use memory.

HISTORY

calc was originally developed around 1984 and has been maintained as a feature-rich alternative to bc.

SEE ALSO

bc(1), dc(1), qalc(1)

RESOURCES

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid