[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Source view] [Print] [Project Stats]
Pure-PHP 32-bit BigInteger Engine PHP version 5 and 7
Author: | Jim Wigginton <[email protected]> |
Copyright: | 2017 Jim Wigginton |
License: | http://www.opensource.org/licenses/mit-license.html MIT License |
File Size: | 373 lines (9 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
PHP32:: (22 methods):
initialize()
isValidEngine()
add()
subtract()
multiply()
divide()
modInverse()
extendedGCD()
gcd()
bitwise_and()
bitwise_or()
bitwise_xor()
compare()
equals()
modPow()
powMod()
randomRangePrime()
randomRange()
pow()
min()
max()
between()
initialize($base) X-Ref |
Initialize a PHP32 BigInteger Engine instance param: int $base |
isValidEngine() X-Ref |
Test for engine validity return: bool |
add(PHP32 $y) X-Ref |
Adds two BigIntegers. param: PHP32 $y return: PHP32 |
subtract(PHP32 $y) X-Ref |
Subtracts two BigIntegers. param: PHP32 $y return: PHP32 |
multiply(PHP32 $y) X-Ref |
Multiplies two BigIntegers. param: PHP32 $y return: PHP32 |
divide(PHP32 $y) X-Ref |
Divides two BigIntegers. Returns an array whose first element contains the quotient and whose second element contains the "common residue". If the remainder would be positive, the "common residue" and the remainder are the same. If the remainder would be negative, the "common residue" is equal to the sum of the remainder and the divisor (basically, the "common residue" is the first positive modulo). param: PHP32 $y return: array{PHP32, PHP32} |
modInverse(PHP32 $n) X-Ref |
Calculates modular inverses. Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses. param: PHP32 $n return: false|PHP32 |
extendedGCD(PHP32 $n) X-Ref |
Calculates modular inverses. Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses. param: PHP32 $n return: PHP32[] |
gcd(PHP32 $n) X-Ref |
Calculates the greatest common divisor Say you have 693 and 609. The GCD is 21. param: PHP32 $n return: PHP32 |
bitwise_and(PHP32 $x) X-Ref |
Logical And param: PHP32 $x return: PHP32 |
bitwise_or(PHP32 $x) X-Ref |
Logical Or param: PHP32 $x return: PHP32 |
bitwise_xor(PHP32 $x) X-Ref |
Logical Exclusive Or param: PHP32 $x return: PHP32 |
compare(PHP32 $y) X-Ref |
Compares two numbers. Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite. The reason for this is demonstrated thusly: $x > $y: $x->compare($y) > 0 $x < $y: $x->compare($y) < 0 $x == $y: $x->compare($y) == 0 Note how the same comparison operator is used. If you want to test for equality, use $x->equals($y). {@internal Could return $this->subtract($x), but that's not as fast as what we do do.} param: PHP32 $y return: int in case < 0 if $this is less than $y; > 0 if $this is greater than $y, and 0 if they are equal. |
equals(PHP32 $x) X-Ref |
Tests the equality of two numbers. If you need to see if one number is greater than or less than another number, use BigInteger::compare() param: PHP32 $x return: bool |
modPow(PHP32 $e, PHP32 $n) X-Ref |
Performs modular exponentiation. param: PHP32 $e param: PHP32 $n return: PHP32 |
powMod(PHP32 $e, PHP32 $n) X-Ref |
Performs modular exponentiation. Alias for modPow(). param: PHP32 $e param: PHP32 $n return: PHP32 |
randomRangePrime(PHP32 $min, PHP32 $max) X-Ref |
Generate a random prime number between a range If there's not a prime within the given range, false will be returned. param: PHP32 $min param: PHP32 $max return: false|PHP32 |
randomRange(PHP32 $min, PHP32 $max) X-Ref |
Generate a random number between a range Returns a random number between $min and $max where $min and $max can be defined using one of the two methods: BigInteger::randomRange($min, $max) BigInteger::randomRange($max, $min) param: PHP32 $min param: PHP32 $max return: PHP32 |
pow(PHP32 $n) X-Ref |
Performs exponentiation. param: PHP32 $n return: PHP32 |
min(PHP32 ...$nums) X-Ref |
Return the minimum BigInteger between an arbitrary number of BigIntegers. param: PHP32 ...$nums return: PHP32 |
max(PHP32 ...$nums) X-Ref |
Return the maximum BigInteger between an arbitrary number of BigIntegers. param: PHP32 ...$nums return: PHP32 |
between(PHP32 $min, PHP32 $max) X-Ref |
Tests BigInteger to see if it is between two integers, inclusive param: PHP32 $min param: PHP32 $max return: bool |
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |