Joomla CMS  4.2.2
Documentation des API du CMS Joomla en version 4.2.2
Référence de la classe BigInteger
+ Graphe d'héritage de BigInteger:

Fonctions membres publiques

 plus ($that)
 
 minus ($that)
 
 multipliedBy ($that)
 
 dividedBy ($that, int $roundingMode=RoundingMode::UNNECESSARY)
 
 power (int $exponent)
 
 quotient ($that)
 
 remainder ($that)
 
 quotientAndRemainder ($that)
 
 mod ($that)
 
 modInverse (BigInteger $m)
 
 modPow ($exp, $mod)
 
 powerMod ($exp, $mod)
 
 gcd ($that)
 
 sqrt ()
 
 abs ()
 
 negated ()
 
 and ($that)
 
 or ($that)
 
 xor ($that)
 
 shiftedLeft (int $distance)
 
 shiftedRight (int $distance)
 
 getBitLength ()
 
 getLowestSetBit ()
 
 isEven ()
 
 isOdd ()
 
 testBit (int $n)
 
 compareTo ($that)
 
 getSign ()
 
 toBigInteger ()
 
 toBigDecimal ()
 
 toBigRational ()
 
 toScale (int $scale, int $roundingMode=RoundingMode::UNNECESSARY)
 
 toInt ()
 
 toFloat ()
 
 toBase (int $base)
 
 toArbitraryBase (string $alphabet)
 
 toBytes (bool $signed=true)
 
 __toString ()
 
 serialize ()
 
 unserialize ($value)
 
- Fonctions membres publiques hérités de BigNumber
 isEqualTo ($that)
 
 isLessThan ($that)
 
 isLessThanOrEqualTo ($that)
 
 isGreaterThan ($that)
 
 isGreaterThanOrEqualTo ($that)
 
 isZero ()
 
 isNegative ()
 
 isNegativeOrZero ()
 
 isPositive ()
 
 isPositiveOrZero ()
 
 getSign ()
 
 compareTo ($that)
 
 toBigInteger ()
 
 toBigDecimal ()
 
 toBigRational ()
 
 toScale (int $scale, int $roundingMode=RoundingMode::UNNECESSARY)
 
 toInt ()
 
 toFloat ()
 
 __toString ()
 
 jsonSerialize ()
 

Fonctions membres publiques statiques

static of ($value)
 
static parse (string $number, int $base=10)
 
static fromBase (string $number, int $base)
 
static fromArbitraryBase (string $number, string $alphabet)
 
static fromBytes (string $value, bool $signed=true)
 
static randomBits (int $numBits, ?callable $randomBytesGenerator=null)
 
static randomRange ($min, $max, ?callable $randomBytesGenerator=null)
 
static zero ()
 
static one ()
 
static ten ()
 
- Fonctions membres publiques statiques hérités de BigNumber
static of ($value)
 
static min (... $values)
 
static max (... $values)
 

Fonctions membres protégées

 __construct (string $value)
 

Attributs privés

 $value
 

Membres hérités additionnels

- Fonctions membres protégées statiques hérités de BigNumber
static create (... $args)
 

Description détaillée

An arbitrary-size integer.

All methods accepting a number as a parameter accept either a BigInteger instance, an integer, or a string representing an arbitrary size integer.

-immutable

Documentation des constructeurs et destructeur

◆ __construct()

__construct ( string  $value)
protected

Protected constructor. Use a factory method to obtain an instance.

Paramètres
string$valueA string of digits, with optional leading minus sign.

Références BigInteger\$value, et value.

Documentation des fonctions membres

◆ __toString()

__toString ( )

{}

Références BigInteger\$value.

◆ abs()

abs ( )

Returns the absolute value of this number.

Renvoie
BigInteger

Références $this, BigNumber\isNegative(), et BigInteger\negated().

Référencé par BigInteger\getBitLength(), et BigInteger\toBytes().

◆ and()

and (   $that)

Returns the integer bitwise-and combined with another integer.

This method returns a negative BigInteger if and only if both operands are negative.

Paramètres
BigNumber | int | float | string$thatThe operand. Must be convertible to an integer number.
Renvoie
BigInteger

Références Calculator\get(), BigInteger\of(), et value.

◆ compareTo()

compareTo (   $that)

{}

Références $this, Calculator\get(), BigNumber\of(), et value.

◆ dividedBy()

dividedBy (   $that,
int  $roundingMode = RoundingMode::UNNECESSARY 
)

Returns the result of the division of this number by the given one.

Paramètres
BigNumber | int | float | string$thatThe divisor. Must be convertible to a BigInteger.
int$roundingModeAn optional rounding mode.
Renvoie
BigInteger The result.
Exceptions
MathExceptionIf the divisor is not a valid number, is not convertible to a BigInteger, is zero, or RoundingMode::UNNECESSARY is used and the remainder is not zero.

Références $result, $this, DivisionByZeroException\divisionByZero(), Calculator\get(), BigInteger\of(), et value.

Référencé par BigInteger\shiftedRight().

◆ fromArbitraryBase()

static fromArbitraryBase ( string  $number,
string  $alphabet 
)
static

Parses a string containing an integer in an arbitrary base, using a custom alphabet.

Because this method accepts an alphabet with any character, including dash, it does not handle negative numbers.

Paramètres
string$numberThe number to parse.
string$alphabetThe alphabet, for example '01' for base 2, or '01234567' for base 8.
Renvoie
BigInteger
Exceptions
NumberFormatExceptionIf the given number is empty or contains invalid chars for the given alphabet.

Références $base, NumberFormatException\charNotInAlphabet(), et Calculator\get().

◆ fromBase()

static fromBase ( string  $number,
int  $base 
)
static

Creates a number from a string in a given base.

The string can optionally be prefixed with the + or - sign.

Bases greater than 36 are not supported by this method, as there is no clear consensus on which of the lowercase or uppercase characters should come first. Instead, this method accepts any base up to 36, and does not differentiate lowercase and uppercase characters, which are considered equal.

For bases greater than 36, and/or custom alphabets, use the fromArbitraryBase() method.

Paramètres
string$numberThe number to convert, in the given base.
int$baseThe base of the number, between 2 and 36.
Renvoie
BigInteger
Exceptions
NumberFormatExceptionIf the number is empty, or contains invalid chars for the given base.

Références $base, $result, Calculator\ALPHABET, elseif, Calculator\get(), et BigInteger\zero().

Référencé par NegativeBigIntegerTag\getNormalizedData().

◆ fromBytes()

static fromBytes ( string  $value,
bool  $signed = true 
)
static

Translates a string of bytes containing the binary representation of a BigInteger into a BigInteger.

The input string is assumed to be in big-endian byte-order: the most significant byte is in the zeroth element.

If $signed is true, the input is assumed to be in two's-complement representation, and the leading bit is interpreted as a sign bit. If $signed is false, the input is interpreted as an unsigned number, and the resulting BigInteger will always be positive or zero.

This method can be used to retrieve a number exported by toBytes(), as long as the $signed flags match.

Paramètres
string$valueThe byte string.
bool$signedWhether to interpret as a signed number in two's-complement representation with a leading sign bit.
Renvoie
BigInteger
Exceptions
NumberFormatExceptionIf the string is empty.

Références BigInteger\$value.

◆ gcd()

gcd (   $that)

Returns the greatest common divisor of this number and the given one.

The GCD is always positive, unless both operands are zero, in which case it is zero.

Paramètres
BigNumber | int | float | string$thatThe operand. Must be convertible to an integer number.
Renvoie
BigInteger

Références $this, BigInteger\$value, Calculator\get(), BigInteger\of(), et value.

◆ getBitLength()

getBitLength ( )

Returns the number of bits in the minimal two's-complement representation of this BigInteger, excluding a sign bit.

For positive BigIntegers, this is equivalent to the number of bits in the ordinary binary representation. Computes (ceil(log2(this < 0 ? -this : this+1))).

Renvoie
int

Références BigInteger\abs(), BigNumber\isNegative(), BigInteger\toBase(), et value.

Référencé par BigInteger\getLowestSetBit().

◆ getLowestSetBit()

getLowestSetBit ( )

Returns the index of the rightmost (lowest-order) one bit in this BigInteger.

Returns -1 if this BigInteger contains no one bits.

Renvoie
int

Références $i, $n, $this, et BigInteger\getBitLength().

◆ getSign()

getSign ( )

{}

Références value.

◆ isEven()

isEven ( )

Returns whether this number is even.

Renvoie
bool

Références value.

◆ isOdd()

isOdd ( )

Returns whether this number is odd.

Renvoie
bool

Références value.

◆ minus()

minus (   $that)

Returns the difference of this number and the given one.

Paramètres
BigNumber | int | float | string$thatThe number to subtract. Must be convertible to a BigInteger.
Renvoie
BigInteger The result.
Exceptions
MathExceptionIf the number is not valid, or is not convertible to a BigInteger.

Références $this, BigInteger\$value, Calculator\get(), BigInteger\of(), et value.

◆ mod()

mod (   $that)

Returns the modulo of this number and the given one.

The modulo operation yields the same result as the remainder operation when both operands are of the same sign, and may differ when signs are different.

The result of the modulo operation, when non-zero, has the same sign as the divisor.

Paramètres
BigNumber | int | float | string$thatThe divisor. Must be convertible to a BigInteger.
Renvoie
BigInteger
Exceptions
DivisionByZeroExceptionIf the divisor is zero.

Références BigInteger\$value, Calculator\get(), DivisionByZeroException\modulusMustNotBeZero(), BigInteger\of(), et value.

◆ modInverse()

modInverse ( BigInteger  $m)

Returns the modular multiplicative inverse of this BigInteger modulo $m.

Paramètres
BigInteger$m
Renvoie
BigInteger
Exceptions
DivisionByZeroExceptionIf $m is zero.
NegativeNumberExceptionIf $m is negative.
MathExceptionIf this BigInteger has no multiplicative inverse mod m (that is, this BigInteger is not relatively prime to m).

Références BigInteger\$value, Calculator\get(), BigNumber\isNegative(), DivisionByZeroException\modulusMustNotBeZero(), null, value, et BigInteger\zero().

◆ modPow()

modPow (   $exp,
  $mod 
)

Returns this number raised into power with modulo.

This operation only works on positive numbers.

Paramètres
BigNumber | int | float | string$expThe positive exponent.
BigNumber | int | float | string$modThe modulus. Must not be zero.
Renvoie
BigInteger
Exceptions
NegativeNumberExceptionIf any of the operands is negative.
DivisionByZeroExceptionIf the modulus is zero.

Références $mod, $result, Calculator\get(), BigNumber\isNegative(), DivisionByZeroException\modulusMustNotBeZero(), BigInteger\of(), et value.

Référencé par BigInteger\powerMod().

◆ multipliedBy()

multipliedBy (   $that)

Returns the product of this number and the given one.

Paramètres
BigNumber | int | float | string$thatThe multiplier. Must be convertible to a BigInteger.
Renvoie
BigInteger The result.
Exceptions
MathExceptionIf the multiplier is not a valid number, or is not convertible to a BigInteger.

Références $this, BigInteger\$value, Calculator\get(), BigInteger\of(), et value.

Référencé par BigInteger\shiftedLeft().

◆ negated()

negated ( )

Returns the inverse of this number.

Renvoie
BigInteger

Références Calculator\get(), et value.

Référencé par BigInteger\abs().

◆ of()

◆ one()

◆ or()

or (   $that)

Returns the integer bitwise-or combined with another integer.

This method returns a negative BigInteger if and only if either of the operands is negative.

Paramètres
BigNumber | int | float | string$thatThe operand. Must be convertible to an integer number.
Renvoie
BigInteger

Références Calculator\get(), BigInteger\of(), et value.

◆ parse()

static parse ( string  $number,
int  $base = 10 
)
static

Parses a string containing an integer in an arbitrary base.

Obsolète:
will be removed in version 0.9 - use fromBase() instead

The string can optionally be prefixed with the + or - sign. For bases greater than 10, both uppercase and lowercase letters are allowed.

Paramètres
string$numberThe number to parse.
int$baseThe base of the number, between 2 and 36.
Renvoie
BigInteger
Exceptions

Références $base.

◆ plus()

plus (   $that)

Returns the sum of this number and the given one.

Paramètres
BigNumber | int | float | string$thatThe number to add. Must be convertible to a BigInteger.
Renvoie
BigInteger The result.
Exceptions
MathExceptionIf the number is not valid, or is not convertible to a BigInteger.

Références $this, BigInteger\$value, Calculator\get(), BigInteger\of(), et value.

◆ power()

power ( int  $exponent)

Returns this number exponentiated to the given value.

Paramètres
int$exponentThe exponent.
Renvoie
BigInteger The result.
Exceptions

Références $this, Calculator\get(), Calculator\MAX_POWER, BigInteger\one(), et value.

Référencé par BigInteger\shiftedLeft().

◆ powerMod()

powerMod (   $exp,
  $mod 
)

Returns this number raised into power with modulo.

Obsolète:
Use modPow() instead.
Paramètres
BigNumber | int | float | string$expThe positive exponent.
BigNumber | int | float | string$modThe modulus. Must not be zero.
Renvoie
BigInteger
Exceptions
NegativeNumberExceptionIf any of the operands is negative.
DivisionByZeroExceptionIf the modulus is zero.

Références $mod, et BigInteger\modPow().

◆ quotient()

quotient (   $that)

Returns the quotient of the division of this number by the given one.

Paramètres
BigNumber | int | float | string$thatThe divisor. Must be convertible to a BigInteger.
Renvoie
BigInteger
Exceptions
DivisionByZeroExceptionIf the divisor is zero.

Références $this, DivisionByZeroException\divisionByZero(), Calculator\get(), BigInteger\of(), et value.

Référencé par BigInteger\shiftedRight().

◆ quotientAndRemainder()

quotientAndRemainder (   $that)

Returns the quotient and remainder of the division of this number by the given one.

Paramètres
BigNumber | int | float | string$thatThe divisor. Must be convertible to a BigInteger.
Renvoie
BigInteger[] An array containing the quotient and the remainder.
Exceptions
DivisionByZeroExceptionIf the divisor is zero.

Références DivisionByZeroException\divisionByZero(), Calculator\get(), BigInteger\of(), et value.

◆ randomBits()

static randomBits ( int  $numBits,
?callable  $randomBytesGenerator = null 
)
static

Generates a pseudo-random number in the range 0 to 2^numBits - 1.

Using the default random bytes generator, this method is suitable for cryptographic use.

Paramètres
int$numBitsThe number of bits.
callable | null$randomBytesGeneratorA function that accepts a number of bytes as an integer, and returns a string of random bytes of the given length. Defaults to the random_bytes() function.
Renvoie
BigInteger
Exceptions

Références null, et BigInteger\zero().

◆ randomRange()

static randomRange (   $min,
  $max,
?callable  $randomBytesGenerator = null 
)
static

Generates a pseudo-random number between $min and $max.

Using the default random bytes generator, this method is suitable for cryptographic use.

Paramètres
BigNumber | int | float | string$minThe lower bound. Must be convertible to a BigInteger.
BigNumber | int | float | string$maxThe upper bound. Must be convertible to a BigInteger.
callable | null$randomBytesGeneratorA function that accepts a number of bytes as an integer, and returns a string of random bytes of the given length. Defaults to the random_bytes() function.
Renvoie
BigInteger
Exceptions
MathExceptionIf one of the parameters cannot be converted to a BigInteger, or $min is greater than $max.

Références BigInteger\of().

◆ remainder()

remainder (   $that)

Returns the remainder of the division of this number by the given one.

The remainder, when non-zero, has the same sign as the dividend.

Paramètres
BigNumber | int | float | string$thatThe divisor. Must be convertible to a BigInteger.
Renvoie
BigInteger
Exceptions
DivisionByZeroExceptionIf the divisor is zero.

Références DivisionByZeroException\divisionByZero(), Calculator\get(), BigInteger\of(), value, et BigInteger\zero().

◆ serialize()

serialize ( )

This method is required by interface Serializable and SHOULD NOT be accessed directly.

Références BigInteger\$value.

◆ shiftedLeft()

shiftedLeft ( int  $distance)

Returns the integer left shifted by a given number of bits.

Paramètres
int$distanceThe distance to shift.
Renvoie
BigInteger

Références $this, BigInteger\multipliedBy(), BigInteger\of(), BigInteger\power(), et BigInteger\shiftedRight().

Référencé par BigInteger\shiftedRight().

◆ shiftedRight()

shiftedRight ( int  $distance)

Returns the integer right shifted by a given number of bits.

Paramètres
int$distanceThe distance to shift.
Renvoie
BigInteger

Références $this, BigInteger\dividedBy(), BigNumber\isPositiveOrZero(), BigInteger\of(), BigInteger\quotient(), BigInteger\shiftedLeft(), et RoundingMode\UP.

Référencé par BigInteger\shiftedLeft(), et BigInteger\testBit().

◆ sqrt()

sqrt ( )

Returns the integer square root number of this number, rounded down.

The result is the largest x such that x² ≤ n.

Renvoie
BigInteger
Exceptions
NegativeNumberExceptionIf this number is negative.

Références BigInteger\$value, Calculator\get(), et value.

◆ ten()

static ten ( )
static

Returns a BigInteger representing ten.

Renvoie
BigInteger

-pure

-suppress ImpureStaticVariable

Références null.

Référencé par BigRational\ten().

◆ testBit()

testBit ( int  $n)

Returns true if and only if the designated bit is set.

Computes ((this & (1<<n)) != 0).

Paramètres
int$nThe bit to test, 0-based.
Renvoie
bool
Exceptions

Références $n, et BigInteger\shiftedRight().

◆ toArbitraryBase()

toArbitraryBase ( string  $alphabet)

Returns a string representation of this number in an arbitrary base with a custom alphabet.

Because this method accepts an alphabet with any character, including dash, it does not handle negative numbers; a NegativeNumberException will be thrown when attempting to call this method on a negative number.

Paramètres
string$alphabetThe alphabet, for example '01' for base 2, or '01234567' for base 8.
Renvoie
string
Exceptions
NegativeNumberExceptionIf this number is negative.

Références $base, Calculator\get(), et value.

◆ toBase()

toBase ( int  $base)

Returns a string representation of this number in the given base.

The output will always be lowercase for bases greater than 10.

Paramètres
int$base
Renvoie
string
Exceptions

Références $base, BigInteger\$value, Calculator\get(), et value.

Référencé par UnsignedIntegerObject\createBigInteger(), et BigInteger\getBitLength().

◆ toBigDecimal()

toBigDecimal ( )

{}

Références BigNumber\create(), et value.

Référencé par BigInteger\toScale().

◆ toBigInteger()

toBigInteger ( )

{}

Références $this.

◆ toBigRational()

toBigRational ( )

{}

Références $this, BigNumber\create(), et BigInteger\one().

◆ toBytes()

toBytes ( bool  $signed = true)

Returns a string of bytes containing the binary representation of this BigInteger.

The string is in big-endian byte-order: the most significant byte is in the zeroth element.

If $signed is true, the output will be in two's-complement representation, and a sign bit will be prepended to the output. If $signed is false, no sign bit will be prepended, and this method will throw an exception if the number is negative.

The string will contain the minimum number of bytes required to represent this BigInteger, including a sign bit if $signed is true.

This representation is compatible with the fromBytes() factory method, as long as the $signed flags match.

Paramètres
bool$signedWhether to output a signed number in two's-complement representation with a leading sign bit.
Renvoie
string
Exceptions
NegativeNumberExceptionIf $signed is false, and the number is negative.

Références BigInteger\abs(), et BigNumber\isNegative().

◆ toFloat()

toFloat ( )

{}

Références BigInteger\$value.

◆ toInt()

◆ toScale()

toScale ( int  $scale,
int  $roundingMode = RoundingMode::UNNECESSARY 
)

{}

Références BigInteger\toBigDecimal().

◆ unserialize()

unserialize (   $value)

This method is only here to implement interface Serializable and cannot be accessed directly.

Références BigInteger\$value, et value.

◆ xor()

xor (   $that)

Returns the integer bitwise-xor combined with another integer.

This method returns a negative BigInteger if and only if exactly one of the operands is negative.

Paramètres
BigNumber | int | float | string$thatThe operand. Must be convertible to an integer number.
Renvoie
BigInteger

Références Calculator\get(), BigInteger\of(), et value.

◆ zero()

static zero ( )
static

Returns a BigInteger representing zero.

Renvoie
BigInteger

-pure

-suppress ImpureStaticVariable

Références null.

Référencé par BigInteger\fromBase(), BigInteger\modInverse(), BigInteger\randomBits(), BigInteger\remainder(), et BigRational\zero().

Documentation des champs

◆ $value


La documentation de cette classe a été générée à partir du fichier suivant :