____ _ _ ____ ___ | _ \| | | | \ /___) | | | | |_| | | | |___ | |_| |_|____/|_|_|_(___/

nums is a cli calculator that uses postfix notation and can accept piped data.

nums requires a go compiler. It uses the standard library only and should run fine on any system with said interpreter installed.

```
git clone https://tildegit.org/sloum/nums && cd nums
go install
```

If after running the above your system cannot find the nums executable you may need to add your go installs folder to your $PATH. You can alternately build locally with go build.

nums is a fairly simple program. Like a few of my other programs (nimf, tally, gnums), nums uses postfix, or reverse polish, notation.

WikiPedia: Reverse Polish Notation

Once you are comfortable with the concept, nums should be very straightforward. When invoked/run nothing is printed to the screen and you may type in your calculations. Numbers and operators can be separated by any number of whitespace characters and will be calculated from left to right upon the enter key being pressed. The output will be the current stack state. You can then type in more calculations that affect the stack. There are a number of available functions/operators available, including the ability to clear the stack and start over.

To exit nums simply press enter with no other text on the input line.

- -p: Take input from a pipe
- -h: Print help and exit

The following commands all have a three character version and a single character version. Either one is valid. The operators are case insensitive.

- +, add: Adds the top two values on the stack
- -, sub: Subtracts the top stack value from the value underneath it
- /, div: Divides the top two stack values with the top of stack being the divisor and the value below it on the stack being the dividend
- *, mul: Multiplies the top two values on the stack
- ^, pow: Raises the value underneath top of stack to the power of top of stack
- @, rnd: Rounds the value underneath top of stack to the number of decimal places represented by top of stack. If top of stack is not a whole number an error will result
- >, cil: Performs a ceiling function on the top of stack (rounds it up to the next whole number)
- <, flr: Performs a floor function on the top of stack (rounds it down to the next whole number)
- |, abs: Takes the top value from the stack and leaves its absolute value
- !, inv: Multiplies top of stack by -1
- V, sqt: Takes the top value from the stack and leaves its square root

The following commands operate on the stack, rather than as numerical operations:

- x, swp: Swap the position of the top two values on the stack
- #, dup: Duplicate/copy the value on top of the stack such that the copy is now above the original on the stack
- _, clr: Clear the stack (wipe out all values and start over)
- ., drp: Drop the top value on the stack (remove it and throw it away)
- ?, help: Prints this help message

To use data from a command line pipe use the -p flag, for example:

```
echo "2 2 +" | nums -p
```

The above example would output 4, but without the -p flag would produce a runtime panic.