Commit | Line | Data |
---|---|---|
14d4f286 S |
1 | <?php |
2 | /** | |
3 | * A class for arbitrary precision math functions implemented using GMP | |
4 | * | |
5 | * PHP version 5.3 | |
6 | * | |
7 | * @category PHPCryptLib | |
8 | * @package Core | |
9 | * @subpackage BigMath | |
10 | * @author Anthony Ferrara <ircmaxell@ircmaxell.com> | |
11 | * @copyright 2011 The Authors | |
12 | * @license http://www.opensource.org/licenses/mit-license.html MIT License | |
13 | * @version Build @@version@@ | |
14 | */ | |
15 | namespace CryptLib\Core\BigMath; | |
16 | ||
17 | /** | |
18 | * A class for arbitrary precision math functions implemented using GMP | |
19 | * | |
20 | * @category PHPCryptLib | |
21 | * @package Core | |
22 | * @subpackage BigMath | |
23 | */ | |
24 | class GMP extends \CryptLib\Core\BigMath { | |
25 | ||
26 | /** | |
27 | * Add two numbers together | |
28 | * | |
29 | * @param string $left The left argument | |
30 | * @param string $right The right argument | |
31 | * | |
32 | * @return A base-10 string of the sum of the two arguments | |
33 | */ | |
34 | public function add($left, $right) { | |
35 | return gmp_strval(gmp_add($left, $right)); | |
36 | } | |
37 | ||
38 | /** | |
39 | * Subtract two numbers | |
40 | * | |
41 | * @param string $left The left argument | |
42 | * @param string $right The right argument | |
43 | * | |
44 | * @return A base-10 string of the difference of the two arguments | |
45 | */ | |
46 | public function subtract($left, $right) { | |
47 | return gmp_strval(gmp_sub($left, $right)); | |
48 | } | |
49 | ||
50 | } |