Rev 846 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 846 | Rev 874 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | /** |
3 | /** |
4 | * GMP BigInteger Engine |
4 | * GMP BigInteger Engine |
5 | * |
5 | * |
6 | * PHP version 5 and 7 |
6 | * PHP version 5 and 7 |
7 | * |
7 | * |
- | 8 | * @category Math |
|
- | 9 | * @package BigInteger |
|
8 | * @author Jim Wigginton <terrafrost@php.net> |
10 | * @author Jim Wigginton <terrafrost@php.net> |
9 | * @copyright 2017 Jim Wigginton |
11 | * @copyright 2017 Jim Wigginton |
10 | * @license http://www.opensource.org/licenses/mit-license.html MIT License |
12 | * @license http://www.opensource.org/licenses/mit-license.html MIT License |
11 | * @link http://pear.php.net/package/Math_BigInteger |
13 | * @link http://pear.php.net/package/Math_BigInteger |
12 | */ |
14 | */ |
Line 16... | Line 18... | ||
16 | use phpseclib3\Exception\BadConfigurationException; |
18 | use phpseclib3\Exception\BadConfigurationException; |
17 | 19 | ||
18 | /** |
20 | /** |
19 | * GMP Engine. |
21 | * GMP Engine. |
20 | * |
22 | * |
- | 23 | * @package GMP |
|
21 | * @author Jim Wigginton <terrafrost@php.net> |
24 | * @author Jim Wigginton <terrafrost@php.net> |
- | 25 | * @access public |
|
22 | */ |
26 | */ |
23 | class GMP extends Engine |
27 | class GMP extends Engine |
24 | { |
28 | { |
25 | /** |
29 | /** |
26 | * Can Bitwise operations be done fast? |
30 | * Can Bitwise operations be done fast? |
27 | * |
31 | * |
28 | * @see parent::bitwise_leftRotate() |
32 | * @see parent::bitwise_leftRotate() |
29 | * @see parent::bitwise_rightRotate() |
33 | * @see parent::bitwise_rightRotate() |
- | 34 | * @access protected |
|
30 | */ |
35 | */ |
31 | const FAST_BITWISE = true; |
36 | const FAST_BITWISE = true; |
32 | 37 | ||
33 | /** |
38 | /** |
34 | * Engine Directory |
39 | * Engine Directory |
35 | * |
40 | * |
36 | * @see parent::setModExpEngine |
41 | * @see parent::setModExpEngine |
- | 42 | * @access protected |
|
37 | */ |
43 | */ |
38 | const ENGINE_DIR = 'GMP'; |
44 | const ENGINE_DIR = 'GMP'; |
39 | 45 | ||
40 | /** |
46 | /** |
41 | * Test for engine validity |
47 | * Test for engine validity |
Line 238... | Line 244... | ||
238 | * |
244 | * |
239 | * {@internal Could return $this->subtract($x), but that's not as fast as what we do do.} |
245 | * {@internal Could return $this->subtract($x), but that's not as fast as what we do do.} |
240 | * |
246 | * |
241 | * @param GMP $y |
247 | * @param GMP $y |
242 | * @return int in case < 0 if $this is less than $y; > 0 if $this is greater than $y, and 0 if they are equal. |
248 | * @return int in case < 0 if $this is less than $y; > 0 if $this is greater than $y, and 0 if they are equal. |
- | 249 | * @access public |
|
243 | * @see self::equals() |
250 | * @see self::equals() |
244 | */ |
251 | */ |
245 | public function compare(GMP $y) |
252 | public function compare(GMP $y) |
246 | { |
253 | { |
247 | $r = gmp_cmp($this->value, $y->value); |
254 | $r = gmp_cmp($this->value, $y->value); |
Line 321... | Line 328... | ||
321 | 328 | ||
322 | /** |
329 | /** |
323 | * Absolute value. |
330 | * Absolute value. |
324 | * |
331 | * |
325 | * @return GMP |
332 | * @return GMP |
- | 333 | * @access public |
|
326 | */ |
334 | */ |
327 | public function abs() |
335 | public function abs() |
328 | { |
336 | { |
329 | $temp = new self(); |
337 | $temp = new self(); |
330 | $temp->value = gmp_abs($this->value); |
338 | $temp->value = gmp_abs($this->value); |