Property | Type | Description | |
---|---|---|---|
$blnBcmath | boolean | Efficiency: Is the BC Math extension loaded? |
Method | Description | |
---|---|---|
bcCalc ( mixed $number1, string $action, mixed $number2, boolean $round = false, integer $decimals, integer $precision = 10 ) : mixed | Do simple reliable floating point calculations without the risk of wrong results | |
normaliseOperator ( string $operator ) : string | Normalise operators for bcMath function. | |
normaliseScore ( integer | float $score, integer $min, integer $max, $dps = 1 ) : integer | float | Normalises score according to min & max allowed. If score larger than max, max is returned. If score less than min, min is returned. |
Method | Description | |
---|---|---|
performCalc ( string | integer | float | boolean $number1, string $action, string | integer | float | boolean $number2, boolean $round, integer $decimals, integer $precision ) : integer | float | boolean | Function which performs calculation. |
public static bcCalc ( mixed $number1, string $action, mixed $number2, boolean $round = false, integer $decimals, integer $precision = 10 ) : mixed | ||
$number1 | mixed | Scalar (string/int/float/bool) |
$action | string | Calculation action to execute. Valid input: '+' or 'add' or 'addition', '-' or 'sub' or 'subtract', '*' or 'mul' or 'multiply', '/' or 'div' or 'divide', '%' or 'mod' or 'modulus' '=' or 'comp' or 'compare' |
$number2 | mixed | Scalar (string/int/float/bool) |
$round | boolean | Whether or not to round the result. Defaults to false. Will be disregarded for a compare operation |
$decimals | integer | Decimals for rounding operation. Defaults to 0. |
$precision | integer | Calculation precision. Defaults to 10. |
return | mixed | Calculation result or false if either or the numbers isn't scalar or an invalid operation was passed - for compare the result will always be an integer - for all other operations, the result will either be an integer (preferred) or a float |
public static normaliseOperator ( string $operator ) : string | ||
$operator | string | Operators such as "+", "add" |
return | string |
protected static bool $blnBcmath | ||
return | boolean |