Documentation

GmpMathInterface

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
GMP

baseConvert()

public baseConvert(string $value, int $fromBase, int $toBase) : string
Parameters
$value : string
$fromBase : int
$toBase : int
Return values
string

bitwiseAnd()

Performs a logical AND between two values.

public bitwiseAnd(GMP $first, GMP $other) : GMP
Parameters
$first : GMP
$other : GMP
Return values
GMP

bitwiseXor()

Performs a logical XOR between two values.

public bitwiseXor(GMP $first, GMP $other) : GMP
Parameters
$first : GMP
$other : GMP
Return values
GMP

cmp()

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
string

digestInteger()

public digestInteger(GMP $m) : GMP
Parameters
$m : GMP
Return values
GMP

div()

Divides a number by another.

public div(GMP $dividend, GMP $divisor) : GMP
Parameters
$dividend : GMP
$divisor : GMP
Return values
GMP

equals()

public equals(GMP $first, GMP $other) : bool
Parameters
$first : GMP
$other : GMP
Return values
bool

gcd2()

public gcd2(GMP $a, GMP $m) : GMP
Parameters
$a : GMP
$m : GMP
Return values
GMP

hexDec()

Converts an hexadecimal string to decimal.

public hexDec(string $hexString) : int|string
Parameters
$hexString : string
Return values
int|string

intToFixedSizeString()

public intToFixedSizeString(GMP $x, int $byteSize) : string
Parameters
$x : GMP
$byteSize : int
Return values
string

intToString()

public intToString(GMP $x) : string
Parameters
$x : GMP
Return values
string

inverseMod()

public inverseMod(GMP $a, GMP $m) : GMP
Parameters
$a : GMP
$m : GMP
Return values
GMP

isPrime()

Checks whether a number is a prime.

public isPrime(GMP $n) : bool
Parameters
$n : GMP
Return values
bool

jacobi()

public jacobi(GMP $a, GMP $p) : int
Parameters
$a : GMP
$p : GMP
Return values
int

leftShift()

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
GMP

mod()

Returns the remainder of a division

public mod(GMP $number, GMP $modulus) : GMP
Parameters
$number : GMP
$modulus : GMP
Return values
GMP

mul()

Multiplies a number by another.

public mul(GMP $multiplier, GMP $multiplicand) : GMP
Parameters
$multiplier : GMP
$multiplicand : GMP
Return values
GMP

nextPrime()

Gets the next known prime that is greater than a given prime.

public nextPrime(GMP $currentPrime) : GMP
Parameters
$currentPrime : GMP
Return values
GMP

pow()

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
GMP

powmod()

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
GMP

rightShift()

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
GMP

stringToInt()

public stringToInt(int|string $s) : GMP
Parameters
$s : int|string
Return values
GMP

sub()

Substract one number from another

public sub(GMP $minuend, GMP $subtrahend) : GMP
Parameters
$minuend : GMP
$subtrahend : GMP
Return values
GMP

toString()

Returns the string representation of a returned value.

public toString(GMP $value) : string
Parameters
$value : GMP
Return values
string

        
On this page

Search results