Crates.io | foocalc |
lib.rs | foocalc |
version | 0.1.0 |
source | src |
created_at | 2024-06-13 06:11:42.104602 |
updated_at | 2024-06-13 06:11:42.104602 |
description | A command line RPN calculator with multiple precision and unit support |
homepage | |
repository | https://github.com/blahblahbloopster/calculator-3 |
max_upload_size | |
id | 1270260 |
size | 135,118 |
a command-line RPN calculator
This calculator is RPN, meaning operators are placed after, not between, operands. For instance, 2*3 would be written as 2 3*
, and (1+2)/(3*4) would be 1 2+ 3 4*/
Ctrl+d can be used to exit
Syntax | Behavior | Example |
---|---|---|
<number> |
Push to stack | 1 -> 1 is on the stack |
+ |
Add last two stack items | 1 2+ -> 3 |
- |
Subtract last two stack items | 1 2- -> -1 |
* |
Multiply last two stack items | 1 2* -> 2 |
/ |
Divide last two stack items | 1 2/ -> 0.5 |
^ |
Wxponentiate last two stack items | 1 2^ -> 1 |
'<infix>' |
Infix notation | '(1+2)/(3*4)' -> 0.25 |
<decimal>e<integer> |
The decimal part times 10 to the power of the integer | 123.456e3 -> 123456 |
(<number>, <number>) , (<number> + <number>i) , <number> + <number>i , <number>i |
Complex number | (2, 5) -> 2 + 5i |
<number>`<unit>` |
Unit | 5`m/s` -> 5 meter/second |
to`<unit>` |
Convert units | 5`m/s` to`in/hour` -> 708661.(...) inch/hour |
`<unit>` |
Set units | 5`m/s` `in/hour` -> 5 inch/hour |
"comment" |
Comment | "this is a comment" |
=<var name> |
Set variable | 5 =aaa -> 'aaa' is now equal to 5 |
<var name> |
Get variable | aaa -> 5 |
<function name> |
Invoke function | pi cos -> -1 |
r |
Remove | rrr -> removes the last 3 items from the stack |
d |
Duplicate | 5 d -> adds 5 to the stack, then adds it again |
s |
Swap | 5 6 s -> 6 5 on the stack |
pretty |
Pretty-print | 123e54 pretty -> 123 septendecillion |
clear |
Clear stack | 1 2 3 4 5 clear -> empty stack |
|<unitname>| |
Define unit | |person| -> you can now do ```1`person```` |
|<unitname> <unitvalue>| |
Define unit | |town 100`people` * 10| |
[<dice>] |
Roll dice | [1d8 + 2d10] |
[P(<dice>)] |
Calculate dice probability distribution | [P(1d8)] shows a histogram and expected value for a d8 |
context |
Show what a quantity means in context | 5`m` context compares 5 meters to the height of the tallest known human, the length of a bus, and the length of a blue whale |
sin, cos, tan, cot, asin, acos, atan, atan2 (coming soon), acot (coming soon), sqrt, ln, log10, log2, logb
cargo build --release
Once it's built, the executable will be at target/release/rustcalc-4
Note that it looks for the units.txt
file in the current directory