
>> (10) - 2 + 4;[0] 4>> 2 * 0x03[1] 6>> $ ^ $$[2] 1296>> $2 % 5[3] 1
$ cargo install --locked --git https://github.com/Techno-coder/calculator
Basic mode does not update on each key press and may work better for lessadvanced terminals.
Evaluation mode reads from the standard input pipe and outputs results directly.
$ echo expression | calculator -e/--evaluation
In order of precedence:
+
- Add-
- Minus*
- Multiply/
- Divide%
- Modulo^
- Power
0x000a
- Hexadecimal0b1010
- Binary0o0012
- Octal1.0
- Floating1e1
- Scientific
$
- Last evaluation result$$
- Second last evaluation result$$...$
- Arbitrary position evaluation result$0
- Variable with identifier0
$aa
- Variable with identifieraa
Functions take the term immediately to the right.Whitespace is required after the function name.
abs
- Absolute valuesqrt
- Square rootcbrt
- Cube rootln
- Natural logarithmlog2
- Binary logarithmlog10
- Decimal logarithm
sin
- Sinecos
- Cosinetan
- Tangentasin
- Inverse sineacos
- Inverse cosineatan
- Inverse tangent
The trigonometric functions can take and return degrees by appending'
:
e
- Euler numberpi
- Pi (3.14)
The coalesce operator combines the previous two terms into a single node.This eliminates the need for parentheses.
is equivalent to:
Repetitions of the coalesce operator will combine more than two terms:
is equivalent to:
Sometimes a combined term is nested inside another:
This can be achieved by leaving whitespace after the first coalescence: