1 | <?php |
||
7 | class BigInt |
||
8 | { |
||
9 | /** |
||
10 | * Number as a base10 integer string. |
||
11 | * |
||
12 | * @var string |
||
13 | */ |
||
14 | private $_num; |
||
15 | |||
16 | /** |
||
17 | * Number as an integer type. |
||
18 | * |
||
19 | * @internal Lazily initialized |
||
20 | * @var int|null |
||
21 | */ |
||
22 | private $_intNum; |
||
23 | |||
24 | /** |
||
25 | * Constructor. |
||
26 | * |
||
27 | * @param string|int $num |
||
28 | */ |
||
29 | 345 | public function __construct($num) |
|
33 | |||
34 | /** |
||
35 | * Get the number as a base10 integer string. |
||
36 | * |
||
37 | * @return string |
||
38 | */ |
||
39 | 208 | public function base10(): string |
|
43 | |||
44 | /** |
||
45 | * Get the number as an integer. |
||
46 | * |
||
47 | * @throws \RuntimeException If number overflows integer size |
||
48 | * @return int |
||
49 | */ |
||
50 | 210 | public function intVal(): int |
|
64 | |||
65 | /** |
||
66 | * Get the maximum integer value. |
||
67 | * |
||
68 | * @return \GMP |
||
69 | */ |
||
70 | 210 | private function _intMaxGmp(): \GMP |
|
78 | |||
79 | /** |
||
80 | * Get the minimum integer value. |
||
81 | * |
||
82 | * @return \GMP |
||
83 | */ |
||
84 | 206 | private function _intMinGmp(): \GMP |
|
92 | |||
93 | /** |
||
94 | * Get the number as a GMP object. |
||
95 | * |
||
96 | * @return \GMP |
||
97 | */ |
||
98 | 124 | public function gmpObj(): \GMP |
|
102 | |||
103 | /** |
||
104 | * |
||
105 | * @return string |
||
106 | */ |
||
107 | 1 | public function __toString() |
|
111 | } |
||
112 |