GmpMathInterface
in
Table of Contents
Methods
- add() : GMP
- Adds two numbers
- baseConvert() : string
- bitwiseAnd() : GMP
- Performs a logical AND between two values.
- bitwiseXor() : GMP
- Performs a logical XOR between two values.
- cmp() : int
- Compares two numbers
- decHex() : string
- Converts a decimal string to hexadecimal.
- digestInteger() : GMP
- div() : GMP
- Divides a number by another.
- equals() : bool
- gcd2() : GMP
- getModularArithmetic() : ModularArithmetic
- getNumberTheory() : NumberTheory
- hexDec() : int|string
- Converts an hexadecimal string to decimal.
- intToFixedSizeString() : string
- intToString() : string
- inverseMod() : GMP
- isPrime() : bool
- Checks whether a number is a prime.
- jacobi() : int
- leftShift() : GMP
- Shifts bits to the left
- mod() : GMP
- Returns the remainder of a division
- mul() : GMP
- Multiplies a number by another.
- nextPrime() : GMP
- Gets the next known prime that is greater than a given prime.
- pow() : GMP
- Raises a number to a power.
- powmod() : GMP
- Calculates the modular exponent of a number.
- rightShift() : GMP
- Shifts bits to the right
- stringToInt() : GMP
- sub() : GMP
- Substract one number from another
- toString() : string
- Returns the string representation of a returned value.
Methods
add()
Adds two numbers
public
add(GMP $augend, GMP $addend) : GMP
Parameters
- $augend : GMP
- $addend : GMP
Return values
GMPbaseConvert()
public
baseConvert(string $value, int $fromBase, int $toBase) : string
Parameters
- $value : string
- $fromBase : int
- $toBase : int
Return values
stringbitwiseAnd()
Performs a logical AND between two values.
public
bitwiseAnd(GMP $first, GMP $other) : GMP
Parameters
- $first : GMP
- $other : GMP
Return values
GMPbitwiseXor()
Performs a logical XOR between two values.
public
bitwiseXor(GMP $first, GMP $other) : GMP
Parameters
- $first : GMP
- $other : GMP
Return values
GMPcmp()
Compares two numbers
public
cmp(GMP $first, GMP $other) : int
Parameters
- $first : GMP
- $other : GMP
Return values
int —less than 0 if first is less than second, 0 if equal, greater than 0 if greater than.
decHex()
Converts a decimal string to hexadecimal.
public
decHex(int|string $decString) : string
Parameters
- $decString : int|string
Return values
stringdigestInteger()
public
digestInteger(GMP $m) : GMP
Parameters
- $m : GMP
Return values
GMPdiv()
Divides a number by another.
public
div(GMP $dividend, GMP $divisor) : GMP
Parameters
- $dividend : GMP
- $divisor : GMP
Return values
GMPequals()
public
equals(GMP $first, GMP $other) : bool
Parameters
- $first : GMP
- $other : GMP
Return values
boolgcd2()
public
gcd2(GMP $a, GMP $m) : GMP
Parameters
- $a : GMP
- $m : GMP
Return values
GMPgetModularArithmetic()
public
getModularArithmetic(GMP $modulus) : ModularArithmetic
Parameters
- $modulus : GMP
Return values
ModularArithmeticgetNumberTheory()
public
getNumberTheory() : NumberTheory
Return values
NumberTheoryhexDec()
Converts an hexadecimal string to decimal.
public
hexDec(string $hexString) : int|string
Parameters
- $hexString : string
Return values
int|stringintToFixedSizeString()
public
intToFixedSizeString(GMP $x, int $byteSize) : string
Parameters
- $x : GMP
- $byteSize : int
Return values
stringintToString()
public
intToString(GMP $x) : string
Parameters
- $x : GMP
Return values
stringinverseMod()
public
inverseMod(GMP $a, GMP $m) : GMP
Parameters
- $a : GMP
- $m : GMP
Return values
GMPisPrime()
Checks whether a number is a prime.
public
isPrime(GMP $n) : bool
Parameters
- $n : GMP
Return values
booljacobi()
public
jacobi(GMP $a, GMP $p) : int
Parameters
- $a : GMP
- $p : GMP
Return values
intleftShift()
Shifts bits to the left
public
leftShift(GMP $number, int $positions) : GMP
Parameters
- $number : GMP
-
Number to shift
- $positions : int
-
Number of positions to shift
Return values
GMPmod()
Returns the remainder of a division
public
mod(GMP $number, GMP $modulus) : GMP
Parameters
- $number : GMP
- $modulus : GMP
Return values
GMPmul()
Multiplies a number by another.
public
mul(GMP $multiplier, GMP $multiplicand) : GMP
Parameters
- $multiplier : GMP
- $multiplicand : GMP
Return values
GMPnextPrime()
Gets the next known prime that is greater than a given prime.
public
nextPrime(GMP $currentPrime) : GMP
Parameters
- $currentPrime : GMP
Return values
GMPpow()
Raises a number to a power.
public
pow(GMP $base, int $exponent) : GMP
Parameters
- $base : GMP
-
The number to raise.
- $exponent : int
-
The power to raise the number to.
Return values
GMPpowmod()
Calculates the modular exponent of a number.
public
powmod(GMP $base, GMP $exponent, GMP $modulus) : GMP
Parameters
- $base : GMP
- $exponent : GMP
- $modulus : GMP
Return values
GMPrightShift()
Shifts bits to the right
public
rightShift(GMP $number, int $positions) : GMP
Parameters
- $number : GMP
-
Number to shift
- $positions : int
-
Number of positions to shift
Return values
GMPstringToInt()
public
stringToInt(int|string $s) : GMP
Parameters
- $s : int|string
Return values
GMPsub()
Substract one number from another
public
sub(GMP $minuend, GMP $subtrahend) : GMP
Parameters
- $minuend : GMP
- $subtrahend : GMP
Return values
GMPtoString()
Returns the string representation of a returned value.
public
toString(GMP $value) : string
Parameters
- $value : GMP