SSCal

SSCal (Stephen's Stack Calculator) is a stack-based postfix terminal calculator, written in pure Go 1.19 by Stephen Malone. It's a fast, reliable, open-source calculator for people who think in postfix.
Installation
Install SSCal with go install...
go install github.com/wirehaiku/SSCal@latest
... or download the latest binary release for your platform.
Usage
Run SSCal to open an interactive session with an empty stack. The stack is printed at the end of each line (if it's not empty).
$ SSCal
> 1 2 3 + +
[ 6 ]
All numbers in SSCal are floating-point, but numbers without decimal portions are presented as integers. Operators are a mix of letters and other symbols, and require a minimum number of arguments.
> 1 2.0 3.456
[ 1 2 3.456 ]
> sum
[ 5.456 ]
> sum
Error: not enough arguments.
Command-Line Options
| Flag |
Description |
-q |
Quiet mode, don't print opening banner. |
-c STRING |
Print the result of STRING and quit. |
Operators
All operators have a minimum number of arguments, shown in parentheses next to the operator's symbol. If the minimum has the suffix F, it indicates a folding operator that applies itself to all numbers on the stack.
Basic Math
| Operator |
Description |
Example |
+ (2) |
Add two numbers. |
2 3 + π‘ [ 5 ] |
- (2) |
Subtract two numbers. |
2 3 - π‘ [ 1 ] |
* (2) |
Multiply two numbers. |
2 3 * π‘ [ 6 ] |
/ (2) |
Divide two numbers. |
2 6 / π‘ [ 3 ] |
% (2) |
Modulo two numbers. |
4 6 % π‘ [ 2 ] |
^ (2) |
Exponent two numbers. |
2 3 ^ π‘ [ 9 ] |
Advanced Math
| Operator |
Description |
Example |
ceil (1) |
Get a number's ceiling. |
1.23 ceil π‘ [ 2 ] |
floor (1) |
Get a number's floor. |
1.23 floor π‘ [ 1 ] |
sqrt (1) |
Get a number's square. |
9 sqrt π‘ [ 3 ] |
min (2) |
Get the smaller number. |
2 3 min π‘ [ 2 ] |
max (2) |
Get the larger number. |
2 3 max π‘ [ 3 ] |
Folding Math
| Operator |
Description |
Example |
sum (2F) |
Add all numbers. |
1 2 3 sum π‘ [ 6 ] |
Stack Operators
| Operator |
Description |
Example |
dupe (1) |
Duplicate the top number. |
1 2 dupe π‘ [ 1 2 2 ] |
roll (1) |
Move the top number to the bottom. |
1 2 3 roll π‘ [ 3 1 2 ] |
swap (2) |
Swap the top two numbers. |
1 2 swap π‘ [ 2 1 ] |
wipe (0) |
Delete all numbers. |
1 2 wipe π‘ [ ] |
Contributions
Please submit all bugs and feature requests to the issue tracker, thank you.