Joomla CMS
4.2.2
Documentation des API du CMS Joomla en version 4.2.2
|
Fonctions membres publiques | |
abs (string $n) | |
neg (string $n) | |
cmp (string $a, string $b) | |
add (string $a, string $b) | |
sub (string $a, string $b) | |
mul (string $a, string $b) | |
divQ (string $a, string $b) | |
divR (string $a, string $b) | |
divQR (string $a, string $b) | |
pow (string $a, int $e) | |
mod (string $a, string $b) | |
modInverse (string $x, string $m) | |
modPow (string $base, string $exp, string $mod) | |
gcd (string $a, string $b) | |
sqrt (string $n) | |
fromBase (string $number, int $base) | |
toBase (string $number, int $base) | |
fromArbitraryBase (string $number, string $alphabet, int $base) | |
toArbitraryBase (string $number, string $alphabet, int $base) | |
divRound (string $a, string $b, int $roundingMode) | |
and (string $a, string $b) | |
or (string $a, string $b) | |
xor (string $a, string $b) | |
Fonctions membres publiques statiques | |
static | set (?Calculator $calculator) |
static | get () |
Champs de données | |
const | MAX_POWER = 1000000 |
const | ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz' |
Fonctions membres protégées | |
init (string $a, string $b) | |
Fonctions membres privées | |
gcdExtended (string $a, string $b, string &$x, string &$y) | |
bitwise (string $operator, string $a, string $b) | |
twosComplement (string $number) | |
toBinary (string $number) | |
toDecimal (string $bytes) | |
Fonctions membres privées statiques | |
static | detect () |
Attributs privés statiques | |
static | $instance |
Performs basic operations on arbitrary size integers.
Unless otherwise specified, all parameters must be validated as non-empty strings of digits, without leading zero, and with an optional leading minus sign if the number is not zero.
Any other parameter format will lead to undefined behaviour. All methods must return strings respecting this format, unless specified otherwise.
|
final |
Returns the absolute value of a number.
string | $n | The number. |
Références $n.
Référencé par Calculator\divRound(), Calculator\gcd(), et Calculator\modInverse().
|
abstract |
Adds two numbers.
string | $a | The augend. |
string | $b | The addend. |
Référencé par Calculator\divRound(), Calculator\fromArbitraryBase(), Calculator\mod(), Calculator\modInverse(), et Calculator\toDecimal().
and | ( | string | $a, |
string | $b | ||
) |
Calculates bitwise AND of two numbers.
This method can be overridden by the concrete implementation if the underlying library has built-in support for bitwise operations.
string | $a | |
string | $b |
Références $b, et Calculator\bitwise().
Référencé par Calculator\bitwise().
|
private |
Performs a bitwise operation on a decimal number.
string | $operator | The operator to use, must be "and", "or" or "xor". |
string | $a | The left operand. |
string | $b | The right operand. |
Références $b, $result, $value, Calculator\and(), elseif, Calculator\init(), Calculator\neg(), Calculator\or(), Calculator\toBinary(), Calculator\toDecimal(), Calculator\twosComplement(), et Calculator\xor().
Référencé par Calculator\and(), Calculator\or(), et Calculator\xor().
|
final |
Compares two numbers.
string | $a | The first number. |
string | $b | The second number. |
Références $b, $result, elseif, et Calculator\init().
Référencé par Calculator\divRound(), Calculator\modInverse(), et NativeCalculator\sqrt().
|
staticprivate |
Returns the fastest available Calculator implementation.
|
abstract |
Returns the quotient of the division of two numbers.
string | $a | The dividend. |
string | $b | The divisor, must not be zero. |
Référencé par Calculator\gcdExtended().
|
abstract |
Returns the quotient and remainder of the division of two numbers.
string | $a | The dividend. |
string | $b | The divisor, must not be zero. |
Référencé par Calculator\divRound(), Calculator\toArbitraryBase(), et Calculator\toBinary().
|
abstract |
Returns the remainder of the division of two numbers.
string | $a | The dividend. |
string | $b | The divisor, must not be zero. |
Référencé par Calculator\gcd(), et Calculator\mod().
|
final |
Performs a rounded division.
Rounding is performed when the remainder of the division is not zero.
string | $a | The dividend. |
string | $b | The divisor. |
int | $roundingMode | The rounding mode. |
Références $b, $r, Calculator\abs(), Calculator\add(), RoundingMode\CEILING, Calculator\cmp(), Calculator\divQR(), RoundingMode\DOWN, RoundingMode\FLOOR, RoundingMode\HALF_CEILING, RoundingMode\HALF_DOWN, RoundingMode\HALF_EVEN, RoundingMode\HALF_FLOOR, RoundingMode\HALF_UP, Calculator\mul(), RoundingNecessaryException\roundingNecessary(), RoundingMode\UNNECESSARY, et RoundingMode\UP.
|
final |
Converts a non-negative number in an arbitrary base using a custom alphabet, to base 10.
string | $number | The number to convert, validated as a non-empty string, containing only chars in the given alphabet/base. |
string | $alphabet | The alphabet that contains every digit, validated as 2 chars minimum. |
int | $base | The base of the number, validated from 2 to alphabet length. |
Références $base, $i, $result, Calculator\add(), et Calculator\mul().
Référencé par Calculator\fromBase().
fromBase | ( | string | $number, |
int | $base | ||
) |
Converts a number from an arbitrary base.
This method can be overridden by the concrete implementation if the underlying library has built-in support for base conversion.
string | $number | The number, positive or zero, non-empty, case-insensitively validated for the given base. |
int | $base | The base of the number, validated from 2 to 36. |
Références $base, et Calculator\fromArbitraryBase().
gcd | ( | string | $a, |
string | $b | ||
) |
Returns the greatest common divisor of the two numbers.
This method can be overridden by the concrete implementation if the underlying library has built-in support for GCD calculations.
string | $a | The first number. |
string | $b | The second number. |
Références $b, Calculator\abs(), et Calculator\divR().
|
private |
Références $b, Calculator\divQ(), Calculator\mod(), Calculator\mul(), et Calculator\sub().
Référencé par Calculator\modInverse().
|
staticfinal |
Returns the Calculator instance to use.
If none has been explicitly set, the fastest available implementation will be returned.
-pure -suppress ImpureStaticProperty
-suppress ImpureMethodCall
Références null.
Référencé par BigInteger\and(), BigDecimal\compareTo(), BigInteger\compareTo(), BigDecimal\dividedBy(), BigInteger\dividedBy(), BigDecimal\exactlyDividedBy(), BigInteger\fromArbitraryBase(), BigInteger\fromBase(), BigInteger\gcd(), BigDecimal\minus(), BigInteger\minus(), BigInteger\mod(), BigInteger\modInverse(), BigInteger\modPow(), BigDecimal\multipliedBy(), BigInteger\multipliedBy(), BigDecimal\negated(), BigInteger\negated(), BigInteger\or(), BigDecimal\plus(), BigInteger\plus(), BigDecimal\power(), BigInteger\power(), BigDecimal\quotient(), BigInteger\quotient(), BigDecimal\quotientAndRemainder(), BigInteger\quotientAndRemainder(), BigDecimal\remainder(), BigInteger\remainder(), BigDecimal\sqrt(), BigInteger\sqrt(), BigInteger\toArbitraryBase(), BigInteger\toBase(), et BigInteger\xor().
|
finalprotected |
Extracts the sign & digits of the operands.
string | $a | The first operand. |
string | $b | The second operand. |
Références $b.
Référencé par NativeCalculator\add(), Calculator\bitwise(), Calculator\cmp(), NativeCalculator\divQR(), et NativeCalculator\mul().
mod | ( | string | $a, |
string | $b | ||
) |
string | $a | |
string | $b | The modulus; must not be zero. |
Références $b, Calculator\add(), et Calculator\divR().
Référencé par Calculator\gcdExtended(), et Calculator\modInverse().
modInverse | ( | string | $x, |
string | $m | ||
) |
Returns the modular multiplicative inverse of $x modulo $m.
If $x has no multiplicative inverse mod m, this method must return null.
This method can be overridden by the concrete implementation if the underlying library has built-in support.
string | $x | |
string | $m | The modulus; must not be negative or zero. |
Références $g, Calculator\abs(), Calculator\add(), Calculator\cmp(), Calculator\gcdExtended(), Calculator\mod(), et null.
|
abstract |
Raises a number into power with modulo.
string | $base | The base number; must be positive or zero. |
string | $exp | The exponent; must be positive or zero. |
string | $mod | The modulus; must be strictly positive. |
|
abstract |
Multiplies two numbers.
string | $a | The multiplicand. |
string | $b | The multiplier. |
Référencé par Calculator\divRound(), Calculator\fromArbitraryBase(), Calculator\gcdExtended(), et Calculator\toDecimal().
|
final |
Negates a number.
string | $n | The number. |
Références $n.
Référencé par NativeCalculator\add(), Calculator\bitwise(), NativeCalculator\divQR(), NativeCalculator\doSub(), NativeCalculator\mul(), et NativeCalculator\sub().
or | ( | string | $a, |
string | $b | ||
) |
Calculates bitwise OR of two numbers.
This method can be overridden by the concrete implementation if the underlying library has built-in support for bitwise operations.
string | $a | |
string | $b |
Références $b, et Calculator\bitwise().
Référencé par Calculator\bitwise().
|
abstract |
Exponentiates a number.
string | $a | The base number. |
int | $e | The exponent, validated as an integer between 0 and MAX_POWER. |
|
staticfinal |
Sets the Calculator instance to use.
An instance is typically set only in unit tests: the autodetect is usually the best option.
Calculator | null | $calculator | The calculator instance, or NULL to revert to autodetect. |
|
abstract |
Returns the square root of the given number, rounded down.
The result is the largest x such that x² ≤ n. The input MUST NOT be negative.
string | $n | The number. |
|
abstract |
Subtracts two numbers.
string | $a | The minuend. |
string | $b | The subtrahend. |
Référencé par Calculator\gcdExtended().
|
final |
Converts a non-negative number to an arbitrary base using a custom alphabet.
string | $number | The number to convert, positive or zero, following the Calculator conventions. |
string | $alphabet | The alphabet that contains every digit, validated as 2 chars minimum. |
int | $base | The base to convert to, validated from 2 to alphabet length. |
Références $base, $result, et Calculator\divQR().
Référencé par Calculator\toBase().
toBase | ( | string | $number, |
int | $base | ||
) |
Converts a number to an arbitrary base.
This method can be overridden by the concrete implementation if the underlying library has built-in support for base conversion.
string | $number | The number to convert, following the Calculator conventions. |
int | $base | The base to convert to, validated from 2 to 36. |
Références $base, et Calculator\toArbitraryBase().
|
private |
Converts a decimal number to a binary string.
string | $number | The number to convert, positive or zero, only digits. |
Références $result, et Calculator\divQR().
Référencé par Calculator\bitwise().
|
private |
Returns the positive decimal representation of a binary number.
string | $bytes | The bytes representing the number. |
Références $i, $result, Calculator\add(), et Calculator\mul().
Référencé par Calculator\bitwise().
|
private |
string | $number | A positive, binary number. |
Références $i.
Référencé par Calculator\bitwise().
xor | ( | string | $a, |
string | $b | ||
) |
Calculates bitwise XOR of two numbers.
This method can be overridden by the concrete implementation if the underlying library has built-in support for bitwise operations.
string | $a | |
string | $b |
Références $b, et Calculator\bitwise().
Référencé par Calculator\bitwise().
|
staticprivate |
const ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz' |
The alphabet for converting from and to base 2 to 36, lowercase.
Référencé par BigInteger\fromBase().
const MAX_POWER = 1000000 |
The maximum exponent value allowed for the pow() method.
Référencé par BigDecimal\power(), et BigInteger\power().