@pranavkok/mathterm
v1.3.12
Published
A simple math calculator that runs right in your terminal. No browser, no app — just type a command and get your answer instantly.
Downloads
497
Readme
mathterm
A simple math calculator that runs right in your terminal. No browser, no app — just type a command and get your answer instantly.
Installation
npm install -g @pranavkok/mathtermUsage
Once installed, just run:
mathtermcliYou'll see a prompt like this:
Calculating ...
mathterm >From here, type any math command and hit enter.
Commands
| Command | What it does | Example |
|---|---|---|
| add | Adds all the numbers | add 5 10 3 → 18 |
| sub | Subtracts from the first number | sub 20 4 1 → 15 |
| mul | Multiplies all the numbers | mul 2 3 4 → 24 |
| div | Divides the first number by the rest | div 100 5 2 → 10 |
| solve | Evaluates any math expression | solve 2 + 3 * 4 → 14 |
| percentage | Finds what percent one number is of another | percentage 10 100 → 10 |
| rand | Generates a random number (0–100 or min–max) | rand 1 6 → random 1–6 |
| convert | Converts between units | convert 100 cm m → 1 |
| help | Shows all available commands | help |
| done | Exits the program | done |
Supported Units
| Category | Units |
|---|---|
| Length | mm, cm, m, km, in/inch, ft/foot, yd/yard, mile |
| Weight | mg, g, kg, ton, oz, lb |
| Volume | ml, l/liter/litre, gal/gallon, qt/quart, pt/pint, cup, floz |
| Time | ms, s/sec, min, hr/hour, day, week, month, year |
| Temperature | c/celsius, f/fahrenheit, k/kelvin |
You can convert between any two units in the same category — e.g.
convert 5 km mile,convert 100 f c,convert 2 hr min.
Example Session
Calculating ...
mathterm > add 10 20 30
Answer is 60
mathterm > sub 100 25 15
Answer is 60
mathterm > mul 3 4
Answer is 12
mathterm > div 200 4
Answer is 50
mathterm > solve 2 + 3 * 4
Answer is 14
mathterm > solve (10 + 5) / 3
Answer is 5
mathterm > percentage 20 80
Answer is 25
mathterm > rand 1 10
7
mathterm > convert 100 cm m
Answer is 1
mathterm > convert 5 km mile
Answer is 3.106855961174092
mathterm > convert 212 f c
Answer is 100
mathterm > convert 2 hr min
Answer is 120
mathterm > convert 5 kg lb
Answer is 11.023113109243878
mathterm > convert 1 gal l
Answer is 3.78541
mathterm > done
Goodbye!Notes
- You can pass more than two numbers to any command — it'll chain the operation across all of them
- Use
solvefor complex expressions with parentheses, operator precedence, decimals, etc. - Use
percentageto quickly find what percent a part is of a whole (it computes(part / whole) * 100) - Use
randto generate random numbers — runrandalone for 0–100, orrand <min> <max>for a custom range (e.g.rand 1 6for dice) convertsupports any-to-any conversion within the same category (Length, Weight, Volume, Time, Temperature)- Temperature conversions use proper formulas (not just ratios), so
convert 32 f cgives you exactly0 - Type
helpanytime if you forget the commands - Type
donewhen you're finished — it'll say goodbye :)
License
ISC
