aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md10
1 files changed, 7 insertions, 3 deletions
diff --git a/README.md b/README.md
index 34b59c4..836612e 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
# A simple and extensible math expressions calculator
## Features:
-* Built in support for +, -, *, / and power (^) operators
+* Built in support for +, -, *, %, / and power (^) operators
* Paratheses () and arrays [] are fully supported
* Logical operators (==, !=, <, <, >=, <=, &&, ||)
* Built in support for most PHP math functions
@@ -101,7 +101,7 @@ $executor->calculate('avarage(1, 3, 4, 8)'); // 4
```
## Operators:
-Default operators: `+ - * / ^`
+Default operators: `+ - * / % ^`
Add custom operator to executor:
@@ -111,7 +111,7 @@ use NXP\Classes\Operator;
$executor->addOperator(new Operator(
'%', // Operator sign
false, // Is right associated operator
- 170, // Operator priority
+ 180, // Operator priority
function (&$stack)
{
$op2 = array_pop($stack);
@@ -189,6 +189,10 @@ $calculator->setVarNotFoundHandler(
);
```
+## Floating Point BCMath Support
+By default, `MathExecutor` uses PHP floating point math, but if you need a fixed precision, call **useBCMath()**. Precision defaults to 2 decimal points, or pass the required number.
+`WARNING`: Functions may return a PHP floating point number. By doing the basic math functions on the results, you will get back a fixed number of decimal points. Use a plus sign in from of any stand alone function to return the proper number of decimal places.
+
## Division By Zero Support:
Division by zero throws a `\NXP\Exception\DivisionByZeroException` by default
```php