2c6496f7084231279f40c288a960dc464a6fb331
				
			
			
		
	PHP Calc
The CLI calculator you never knew you needed. Also usable as a library!
Usage
CLI
Call with an expression to evaluate:
$ calc "42*atan(pi/2)"
42.163162517863
Or call without arguments to go interactive:
$ calc
~ 42*atan(pi/2)
  42.163162517863
Library
As simple as falling off a rock:
use NoccyLabs\PhpCalc\Calculator;
$calc = new Calculator();
$result = $calc->evaluate("42 * atan(pi/2)");
What it does
Supported operations:
- +addition
- -subtraction
- *multiplication
- /division
- ^exponent/raise to power
Supported functions:
- abs
- acos
- acosh
- asin
- asin
- atan
- atanh
- ceil
- cos
- cosh
- floor
- sin
- sinh
- log
- round
- sqrt
- tan
- tanh
Constants:
- pi
Useful tips
- You can set the precision using the _pvariable. If the expression is passed on the command line, prepend the variable followed by a semicolon, such as_p=2;pifor the result 3.14.
Bugs and known issues
- Negative numbers and subtraction should be surrounded by whitespace to parse properly.
Passing 2-1will result in2and-1, returning 2 and a warning. Passing2 - 1will return1as expected, as will2- 1.
Description
				
					Languages
				
				
								
								
									PHP
								
								100%