Brendan Pinnell - 2012-11-23 07:46:29
I have figured out how to allow use of round(), floor() and ceil() functions by adding them to the array $fb. Now I would like to enable min() and max(). The reason I'd like these available, is I want to be able to cap the value my formula returns, eg:
for ($i = 0; $ < 10; $i++) {
$m->evaluate("i=$i");
// Calculate 2 * i, capping at 6
print($m->evaluate("min(2i, 6)") . "\n";
}
Desired output:
0
2
4
6
6
6
6
...
The example is trivial but I have a proper use in mind
The error I get is Warning: too many arguments (2 given, 1 expected) in evalmath.php on line 361
I can see that the problem is that min() and max() require 2 (or more) arguments whereas only one is allowed for EvalMath to use built-in functions.