Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Getting Started

Installation

Build from source (requires Rust):

git clone https://github.com/holgertkey/ccalc
cd ccalc
cargo build --release
# binary: target/release/ccalc

Usage modes

Interactive REPL

ccalc

A prompt shows the current value of ans. Type an expression and press Enter. Type help for a reference, or help <topic> for a specific section.

[ 0 ]: 2 ^ 32
[ 4294967296 ]: / 1024
[ 4194304 ]: sqrt()
[ 2048 ]: help functions
...
[ 2048 ]: exit

Single expression (argument mode)

ccalc "EXPR"

Evaluates the expression, prints the result, and exits. Useful for shell scripts.

$ ccalc "2 ^ 32"
4294967296

$ ccalc "sqrt(2)"
1.4142135624

Script file

Pass a .m or .ccalc file as an argument:

ccalc script.m
ccalc examples/mortgage.ccalc

Pipe / non-interactive mode

When stdin is not a terminal, ccalc reads lines one by one and prints one result per line. ans carries over across lines.

$ echo "sin(pi / 6)" | ccalc
0.5

$ printf "100\n/ 4\n+ 5" | ccalc
100
25
30

$ ccalc < formula.txt

Command-line options

FlagDescription
-h, --helpPrint help and exit
-v, --versionPrint version and exit