MMOframework
Why AI Playground Libraries Documentation Search Agency
FR EN
Index

MMO\math

MMO\math · 19 symbols · generated 27 Oct 2026

function

binomialCoefficient

functions.php:189

Compute the binomial coefficient $n! / ($k! * ($n - $k)!)

function binomialCoefficient(int $n, int $k): float
Namespace
MMO\math
$nint
$kint
returnsfloat
Call graph
function

bisection

functions.php:203

Find a root of a continuous function (fn(x) = 0) using the bisection method

function bisection(callable $fn, int|float $a, int|float $b, int|float $epsilon = 0.01): ?float
Namespace
MMO\math
See
https://www.geeksforgeeks.org/dsa/program-for-bisection-method/ WARNING: this only determine ONE solution of all the possible solutions
$fncallablefunction(x):int|float
$aint | floatthe smallest number to try from
$bint | floatthe biggest number to try from
$epsilon = 0.01int | floatthe minimal step
returnsnull | floatif null, could not determine a solution
function

compare

functions.php:76

Compare two values

function compare(mixed $a, mixed $b): int|bool
Namespace
MMO\math
$amixed
$bmixed
returnsint | bool-1 : $a < $b 0 : $a == $b 1 : $a > $b true: $a === $b
Call graph
function

divide

functions.php:138
function divide(MMO\math\interfaces\iNumber|int|float ...$args): MMO\math\interfaces\iNumber|int|float
Namespace
MMO\math
...$argsiNumber | int | float
returnsiNumber | int | float
Call graph
function

factorial

functions.php:176

Do factorial of $n n! = n * (n-1) * (n-2) * ........ * 1

function factorial(int $n): int
Namespace
MMO\math
$nint
returnsint
Call graph
function

isNumber

functions.php:44

Test if a value is a float, int or iNumber

function isNumber(mixed $value): bool
Namespace
MMO\math
$valuemixed
returnsbool
function

loopValues

functions.php:255

Get the numbers a value stands for (used by max, min and size) Plain numbers and set iNumber yield their value, an unset iNumber yields nothing, an iDomain (Interval, Domain) yields its limit (start and end, open bounds included as their limit) and any other IteratorAggregate is walked

function loopValues(MMO\math\interfaces\iNumber|IteratorAggregate|int|float $value): Generator
Namespace
MMO\math
$valueiNumber | IteratorAggregate | int | float
returnsGeneratorint|float
Call graph
function

max

functions.php:284

Get the maximum value of a list of numbers (iNumber included)

function max(MMO\math\interfaces\iNumber|IteratorAggregate|int|float ...$values): int|float|null
Namespace
MMO\math
...$valuesiNumber | IteratorAggregate | int | float
returnsint | float | nullnull if no value is known
max(1, 5, 3); //5 max(new Domain([1, 2], [3, 4]), 2); //4.0 max(new Number()); //null
Call graph
function

min

functions.php:303

Get the minimum value of a list of numbers (iNumber included)

function min(MMO\math\interfaces\iNumber|IteratorAggregate|int|float ...$values): int|float|null
Namespace
MMO\math
...$valuesiNumber | IteratorAggregate | int | float
returnsint | float | nullnull if no value is known
min(1, 5, 3); //1 min(new Domain([1, 2], [3, 4]), 2); //1.0 min(new Number()); //null
Call graph
function

minus

functions.php:95
function minus(MMO\math\interfaces\iNumber|int|float ...$args): MMO\math\interfaces\iNumber|int|float
Namespace
MMO\math
...$argsiNumber | int | float
returnsiNumber | int | float
Call graph
function

multiply

functions.php:112

Multiply any number (iNumber included) by a factor

function multiply(MMO\math\interfaces\iNumber|int|float ...$args): MMO\math\interfaces\iNumber|int|float
Namespace
MMO\math
...$argsiNumber | int | float
returnsiNumber | int | float
Call graph
function

number

functions.php:56

Convert any value to a number (int|float)

function number(mixed $value, bool $convertNumber = true, bool $ignoreUnits = true): int|float|null
Namespace
MMO\math
$valuemixedif a string, the value is parsed and it returns an int if it can or a float. if iNumber, it returns its value
$convertNumber = trueboolif false and it is a iNumber, null is returned
$ignoreUnits = trueboolif false and the number has units, null is returned
returnsint | float | nullif null, the value cannot be converted to a number
Call graph
function

operatorRegex

functions.php:353

Get a regular expression used to tokenize a math expression (used by parse)

function operatorRegex(): string
Namespace
MMO\math
returnsstring
Call graph

Used by (1)

function

parse

functions.php:380

Tokenize a mathematical expression

function parse( array|string $exp, ?callable $variableFactory = null, array $customOperators = [], array &$vars = [] ): MMO\math\interfaces\iNumber|string
Namespace
MMO\math
$exparray | stringthe mathematical expression
$variableFactory = nullnull | callablefunction($name): ?iNumber. $name is the name of the variable without '$'. If it returns null, a Number is created
$customOperators = []arraythe custom operators in front of parenthesis (like xxx(..,..)) where xxx is the operator
$vars = []array
returnsiNumber | string
Call graph
function

plus

functions.php:84
function plus(MMO\math\interfaces\iNumber|int|float ...$args): MMO\math\interfaces\iNumber|int|float
Namespace
MMO\math
...$argsiNumber | int | float
returnsiNumber | int | float
Call graph
function

power

functions.php:160
function power(MMO\math\interfaces\iNumber|int|float $a, float $power): MMO\math\interfaces\iNumber|int|float
Namespace
MMO\math
$aiNumber | int | float
$powerfloat
returnsiNumber | int | float
Call graph
function

roundScale

functions.php:23

Round value to the closest power of ten

function roundScale(int|float $value, int $scale = 0, ?bool $roundUp = null): float
Namespace
MMO\math
$valueint | float
$scale = 0intif < 0, it is a numeral precision. ex: -1 => precise to 0.1, -3 => 0.001 if > 0, it is rounded to the closest value. ex: 2 => rounded to 100. 0 => 1, 6 => 1 000 000
$roundUp = nullnull | bool
returnsfloat
Call graph
function

scale

functions.php:34

Get the power of ten the given value is precise to

function scale(int|float $value): int
Namespace
MMO\math
$valueint | float
returnsint
Call graph
function

size

functions.php:323

Get the number of values in the given values

function size(MMO\math\interfaces\iNumber|IteratorAggregate|int|float ...$values): int|float
Namespace
MMO\math
...$valuesiNumber | IteratorAggregate | int | float
returnsint | floatINF if a value holds a range of numbers
size(1, new Number(), new Number(2)); //2 size(new Interval(3, 3)); //1 size(new Interval(1, 2)); //INF
Call graph

Uses (2)

Used by (1)