@@ -21,7 +21,7 @@ |
||
21 | 21 | * @throws IntegrityConstraint |
22 | 22 | * @throws MissingPackage |
23 | 23 | */ |
24 | - public function continuousModulo(NumberInterface|string|int|float $mod): DecimalInterface |
|
24 | + public function continuousModulo(NumberInterface | string | int | float $mod): DecimalInterface |
|
25 | 25 | { |
26 | 26 | |
27 | 27 | $mod = Numbers::makeOrDont(Numbers::IMMUTABLE, $mod, $this->scale+1); |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | public static function radiansToDegrees($radians) |
22 | 22 | { |
23 | 23 | $radians = Numbers::makeOrDont(Numbers::IMMUTABLE, $radians); |
24 | - $pi = Numbers::makePi($radians->getScale() + 2); |
|
24 | + $pi = Numbers::makePi($radians->getScale()+2); |
|
25 | 25 | |
26 | - return $radians->multiply(180)->divide($pi, $radians->getScale() + 2)->round($radians->getScale() - 2)->getValue(NumberBase::Ten); |
|
26 | + return $radians->multiply(180)->divide($pi, $radians->getScale()+2)->round($radians->getScale()-2)->getValue(NumberBase::Ten); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | public static function degreesToRadians($degrees) |
36 | 36 | { |
37 | 37 | $degrees = Numbers::makeOrDont(Numbers::IMMUTABLE, $degrees); |
38 | - $pi = Numbers::makePi($degrees->getScale() + 1); |
|
38 | + $pi = Numbers::makePi($degrees->getScale()+1); |
|
39 | 39 | |
40 | 40 | return $degrees->multiply($pi)->divide(180)->round($degrees->getScale())->getValue(NumberBase::Ten); |
41 | 41 | } |
@@ -20,57 +20,57 @@ discard block |
||
20 | 20 | { |
21 | 21 | |
22 | 22 | const EULER_ZIGZAG = [ |
23 | - '1', // 0 |
|
24 | - '1', // 1 |
|
25 | - '1', // 2 |
|
26 | - '2', // 3 |
|
27 | - '5', // 4 |
|
28 | - '16', // 5 |
|
29 | - '61', // 6 |
|
30 | - '272', // 7 |
|
31 | - '1385', // 8 |
|
32 | - '7936', // 9 |
|
33 | - '50521', // 10 |
|
34 | - '353792', // 11 |
|
35 | - '2702765', // 12 |
|
36 | - '22368256', // 13 |
|
37 | - '199360981', // 14 |
|
38 | - '1903757312', // 15 |
|
39 | - '19391512145', // 16 |
|
40 | - '209865342976', // 17 |
|
41 | - '2404879675441', // 18 |
|
42 | - '29088885112832', // 19 |
|
43 | - '370371188237525', // 20 |
|
44 | - '4951498053124096', // 21 |
|
45 | - '69348874393137901', // 22 |
|
46 | - '1015423886506852352', // 23 |
|
47 | - '15514534163557086905', // 24 |
|
48 | - '246921480190207983616', // 25 |
|
49 | - '4087072509293123892361', // 26 |
|
50 | - '70251601603943959887872', // 27 |
|
51 | - '1252259641403629865468285', // 28 |
|
52 | - '23119184187809597841473536', // 29 |
|
53 | - '441543893249023104553682821', // 30 |
|
54 | - '8713962757125169296170811392', // 31 |
|
55 | - '177519391579539289436664789665', // 32 |
|
56 | - '3729407703720529571097509625856', // 33 |
|
57 | - '80723299235887898062168247453281', // 34 |
|
58 | - '1798651693450888780071750349094912', // 35 |
|
59 | - '41222060339517702122347079671259045', // 36 |
|
60 | - '970982810785059112379399707952152576', // 37 |
|
61 | - '23489580527043108252017828576198947741', // 38 |
|
62 | - '583203324917310043943191641625494290432', // 39 |
|
63 | - '14851150718114980017877156781405826684425', // 40 |
|
64 | - '387635983772083031828014624002175135645696', // 41 |
|
65 | - '10364622733519612119397957304745185976310201', // 42 |
|
66 | - '283727921907431909304183316295787837183229952', // 43 |
|
67 | - '7947579422597592703608040510088070619519273805', // 44 |
|
68 | - '227681379129930886488600284336316164603920777216', // 45 |
|
69 | - '6667537516685544977435028474773748197524107684661', // 46 |
|
70 | - '199500252157859031027160499643195658166340757225472', // 47 |
|
71 | - '6096278645568542158691685742876843153976539044435185', // 48 |
|
72 | - '190169564657928428175235445073924928592047775873499136', // 49 |
|
73 | - '6053285248188621896314383785111649088103498225146815121', // 50 |
|
23 | + '1', // 0 |
|
24 | + '1', // 1 |
|
25 | + '1', // 2 |
|
26 | + '2', // 3 |
|
27 | + '5', // 4 |
|
28 | + '16', // 5 |
|
29 | + '61', // 6 |
|
30 | + '272', // 7 |
|
31 | + '1385', // 8 |
|
32 | + '7936', // 9 |
|
33 | + '50521', // 10 |
|
34 | + '353792', // 11 |
|
35 | + '2702765', // 12 |
|
36 | + '22368256', // 13 |
|
37 | + '199360981', // 14 |
|
38 | + '1903757312', // 15 |
|
39 | + '19391512145', // 16 |
|
40 | + '209865342976', // 17 |
|
41 | + '2404879675441', // 18 |
|
42 | + '29088885112832', // 19 |
|
43 | + '370371188237525', // 20 |
|
44 | + '4951498053124096', // 21 |
|
45 | + '69348874393137901', // 22 |
|
46 | + '1015423886506852352', // 23 |
|
47 | + '15514534163557086905', // 24 |
|
48 | + '246921480190207983616', // 25 |
|
49 | + '4087072509293123892361', // 26 |
|
50 | + '70251601603943959887872', // 27 |
|
51 | + '1252259641403629865468285', // 28 |
|
52 | + '23119184187809597841473536', // 29 |
|
53 | + '441543893249023104553682821', // 30 |
|
54 | + '8713962757125169296170811392', // 31 |
|
55 | + '177519391579539289436664789665', // 32 |
|
56 | + '3729407703720529571097509625856', // 33 |
|
57 | + '80723299235887898062168247453281', // 34 |
|
58 | + '1798651693450888780071750349094912', // 35 |
|
59 | + '41222060339517702122347079671259045', // 36 |
|
60 | + '970982810785059112379399707952152576', // 37 |
|
61 | + '23489580527043108252017828576198947741', // 38 |
|
62 | + '583203324917310043943191641625494290432', // 39 |
|
63 | + '14851150718114980017877156781405826684425', // 40 |
|
64 | + '387635983772083031828014624002175135645696', // 41 |
|
65 | + '10364622733519612119397957304745185976310201', // 42 |
|
66 | + '283727921907431909304183316295787837183229952', // 43 |
|
67 | + '7947579422597592703608040510088070619519273805', // 44 |
|
68 | + '227681379129930886488600284336316164603920777216', // 45 |
|
69 | + '6667537516685544977435028474773748197524107684661', // 46 |
|
70 | + '199500252157859031027160499643195658166340757225472', // 47 |
|
71 | + '6096278645568542158691685742876843153976539044435185', // 48 |
|
72 | + '190169564657928428175235445073924928592047775873499136', // 49 |
|
73 | + '6053285248188621896314383785111649088103498225146815121', // 50 |
|
74 | 74 | ]; |
75 | 75 | |
76 | 76 | /** |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | if ($asCollection) { |
89 | 89 | $sequence = new NumberCollection(); |
90 | 90 | |
91 | - for ($i = 0;$i < $collectionSize;$i++) { |
|
92 | - $sequence->push(self::nthOddNumber($n + $i)); |
|
91 | + for ($i = 0; $i < $collectionSize; $i++) { |
|
92 | + $sequence->push(self::nthOddNumber($n+$i)); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | return $sequence; |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | if ($asCollection) { |
122 | 122 | $sequence = new NumberCollection(); |
123 | 123 | |
124 | - for ($i = 0;$i < $collectionSize;$i++) { |
|
125 | - $sequence->push(self::nthEvenNumber($n + $i)); |
|
124 | + for ($i = 0; $i < $collectionSize; $i++) { |
|
125 | + $sequence->push(self::nthEvenNumber($n+$i)); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | return $sequence; |
@@ -153,14 +153,14 @@ discard block |
||
153 | 153 | if ($asCollection) { |
154 | 154 | $sequence = new NumberCollection(); |
155 | 155 | |
156 | - for ($i = 0;$i < $collectionSize;$i++) { |
|
157 | - $sequence->push(self::nthPowerNegativeOne($n + $i)); |
|
156 | + for ($i = 0; $i < $collectionSize; $i++) { |
|
157 | + $sequence->push(self::nthPowerNegativeOne($n+$i)); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | return $sequence; |
161 | 161 | } |
162 | 162 | |
163 | - return ($n % 2 ? new ImmutableDecimal(-1) : new ImmutableDecimal(1)); |
|
163 | + return ($n%2 ? new ImmutableDecimal(-1) : new ImmutableDecimal(1)); |
|
164 | 164 | |
165 | 165 | } |
166 | 166 | |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | if ($asCollection) { |
181 | 181 | $sequence = new NumberCollection(); |
182 | 182 | |
183 | - for ($i = 0;$i < $collectionSize;$i++) { |
|
184 | - $sequence->push(self::nthEulerZigzag($n + $i)); |
|
183 | + for ($i = 0; $i < $collectionSize; $i++) { |
|
184 | + $sequence->push(self::nthEulerZigzag($n+$i)); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | return $sequence; |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | |
217 | 217 | $scale = $scale ?? 5; |
218 | 218 | |
219 | - $internalScale = (int)ceil($scale*(log10($scale)+1)); |
|
219 | + $internalScale = (int) ceil($scale*(log10($scale)+1)); |
|
220 | 220 | |
221 | 221 | $n = Numbers::makeOrDont(Numbers::IMMUTABLE, $n, $internalScale)->setMode(CalcMode::Precision); |
222 | 222 | |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | |
318 | 318 | $currentPrime = Numbers::make(Numbers::IMMUTABLE, 3); |
319 | 319 | |
320 | - for ($i = 1;$i < $n;$i++) { |
|
320 | + for ($i = 1; $i < $n; $i++) { |
|
321 | 321 | while (!$currentPrime->isPrime()) { |
322 | 322 | $currentPrime = $currentPrime->add(2); |
323 | 323 | } |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | $sequence = new NumberCollection(); |
362 | 362 | $sequence->push($fastFib[0]); |
363 | 363 | $sequence->push($fastFib[1]); |
364 | - for ($i = 0;$i < ($collectionSize-2);$i++) { |
|
364 | + for ($i = 0; $i < ($collectionSize-2); $i++) { |
|
365 | 365 | $sequence->push($sequence->get($i)->add($sequence[$i+1])); |
366 | 366 | } |
367 | 367 |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | * @throws IncompatibleObjectState |
31 | 31 | */ |
32 | 32 | public static function randomInt( |
33 | - int|string|DecimalInterface $min, |
|
34 | - int|string|DecimalInterface $max, |
|
33 | + int | string | DecimalInterface $min, |
|
34 | + int | string | DecimalInterface $max, |
|
35 | 35 | RandomMode $mode = RandomMode::Entropy |
36 | 36 | ): ImmutableDecimal |
37 | 37 | { |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | throw new OptionalExit( |
108 | 108 | 'System error from random_bytes().', |
109 | 109 | 'Ensure your system is configured correctly.', |
110 | - 'A call to random_bytes() threw a system level exception. Most often this is due to a problem with entropy sources in your configuration. Original exception message: ' . $e->getMessage() |
|
110 | + 'A call to random_bytes() threw a system level exception. Most often this is due to a problem with entropy sources in your configuration. Original exception message: '.$e->getMessage() |
|
111 | 111 | ); |
112 | 112 | } |
113 | 113 | } elseif ($mode == RandomMode::Speed) { |
@@ -147,14 +147,14 @@ discard block |
||
147 | 147 | */ |
148 | 148 | $entropyBytes = random_bytes($bytesNeeded->asInt()); |
149 | 149 | $baseTwoBytes = ''; |
150 | - for($i = 0; $i < strlen($entropyBytes); $i++){ |
|
151 | - $baseTwoBytes .= decbin( ord( $entropyBytes[$i] ) ); |
|
150 | + for ($i = 0; $i < strlen($entropyBytes); $i++) { |
|
151 | + $baseTwoBytes .= decbin(ord($entropyBytes[$i])); |
|
152 | 152 | } |
153 | 153 | } catch (Exception $e) { |
154 | 154 | throw new OptionalExit( |
155 | 155 | 'System error from random_bytes().', |
156 | 156 | 'Ensure your system is configured correctly.', |
157 | - 'A call to random_bytes() threw a system level exception. Most often this is due to a problem with entropy sources in your configuration. Original exception message: ' . $e->getMessage() |
|
157 | + 'A call to random_bytes() threw a system level exception. Most often this is due to a problem with entropy sources in your configuration. Original exception message: '.$e->getMessage() |
|
158 | 158 | ); |
159 | 159 | } |
160 | 160 | |
@@ -243,8 +243,8 @@ discard block |
||
243 | 243 | * @throws IncompatibleObjectState |
244 | 244 | */ |
245 | 245 | public static function randomReal( |
246 | - int|string|DecimalInterface $min, |
|
247 | - int|string|DecimalInterface $max, |
|
246 | + int | string | DecimalInterface $min, |
|
247 | + int | string | DecimalInterface $max, |
|
248 | 248 | int $scale, |
249 | 249 | RandomMode $mode = RandomMode::Entropy |
250 | 250 | ): ImmutableDecimal |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * We cannot take advantage of a more efficient check for the top end of the range, so the |
370 | 370 | * less than check is all we need. |
371 | 371 | */ |
372 | - $maxDecimal = str_pad('1', $scale + 1, '0'); |
|
372 | + $maxDecimal = str_pad('1', $scale+1, '0'); |
|
373 | 373 | } else { |
374 | 374 | /** |
375 | 375 | * The max value is guaranteed to have a decimal portion here since we excluded max being |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $roundedPartString = $currentPart ? $decimalPart : $wholePart; |
71 | 71 | $otherPart = $currentPart ? str_split($wholePart) : str_split($decimalPart); |
72 | 72 | $baseLength = $currentPart ? strlen($decimalPart)-1 : strlen($wholePart); |
73 | - $pos = $currentPart ? $places : $baseLength + $places; |
|
73 | + $pos = $currentPart ? $places : $baseLength+$places; |
|
74 | 74 | $carry = 0; |
75 | 75 | |
76 | 76 | if ($currentPart) { |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | break; |
85 | 85 | } |
86 | 86 | |
87 | - $digit = (int)$roundedPart[$pos] + $carry; |
|
87 | + $digit = (int) $roundedPart[$pos]+$carry; |
|
88 | 88 | |
89 | 89 | if ($carry == 0 && $digit == 5) { |
90 | 90 | static::$remainder = substr($roundedPartString, $pos+1); |
@@ -94,12 +94,12 @@ discard block |
||
94 | 94 | |
95 | 95 | if ($pos == 0) { |
96 | 96 | if ($currentPart) { |
97 | - $nextDigit = (int)$otherPart[count($otherPart)-1]; |
|
97 | + $nextDigit = (int) $otherPart[count($otherPart)-1]; |
|
98 | 98 | } else { |
99 | 99 | $nextDigit = 0; |
100 | 100 | } |
101 | 101 | } else { |
102 | - $nextDigit = (int)$roundedPart[$pos-1]; |
|
102 | + $nextDigit = (int) $roundedPart[$pos-1]; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | if ($carry == 0) { |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $remainder = self::remainderCheck(); |
231 | 231 | |
232 | 232 | if ($early == 0) { |
233 | - return ($nextDigit % 2 == 0 && !$remainder) ? 0 : 1; |
|
233 | + return ($nextDigit%2 == 0 && !$remainder) ? 0 : 1; |
|
234 | 234 | } else { |
235 | 235 | return $early == 1 ? 1 : 0; |
236 | 236 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | $remainder = self::remainderCheck(); |
243 | 243 | |
244 | 244 | if ($early == 0) { |
245 | - return ($nextDigit % 2 == 1 && !$remainder) ? 0 : 1; |
|
245 | + return ($nextDigit%2 == 1 && !$remainder) ? 0 : 1; |
|
246 | 246 | } else { |
247 | 247 | return $early == 1 ? 1 : 0; |
248 | 248 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | |
293 | 293 | if ($early == 0 && !$remainder) { |
294 | 294 | $val = self::$alt; |
295 | - self::$alt = (int)!$val; |
|
295 | + self::$alt = (int) !$val; |
|
296 | 296 | |
297 | 297 | return $val; |
298 | 298 | } else { |
@@ -310,9 +310,9 @@ discard block |
||
310 | 310 | $rangeMax = 9; |
311 | 311 | } else { |
312 | 312 | $remainder = substr($remainder, 0, 3); |
313 | - $target = (int)($digit.$remainder); |
|
313 | + $target = (int) ($digit.$remainder); |
|
314 | 314 | $rangeMin = 0; |
315 | - $rangeMax = (int)str_repeat('9', strlen($remainder) + 1); |
|
315 | + $rangeMax = (int) str_repeat('9', strlen($remainder)+1); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | $random = RandomProvider::randomInt($rangeMin, $rangeMax, RandomMode::Speed)->asInt(); |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | } else { |
44 | 44 | $abs = $this instanceof ImmutableDecimal ? $this->abs() : new ImmutableDecimal($this->absValue()); |
45 | 45 | $addScale = $abs->asInt() > $abs->getScale() ? $abs->asInt() : $abs->getScale(); |
46 | - $intScale = $scale + $addScale; |
|
46 | + $intScale = $scale+$addScale; |
|
47 | 47 | $x = new ImmutableDecimal($this->getValue(NumberBase::Ten), $intScale); |
48 | 48 | $x2 = $x->pow(2); |
49 | 49 | $one = new ImmutableDecimal(1, $intScale); |
50 | 50 | |
51 | - $aPart = new class($x2, $intScale) implements ContinuedFractionTermInterface{ |
|
51 | + $aPart = new class($x2, $intScale) implements ContinuedFractionTermInterface { |
|
52 | 52 | private ImmutableDecimal $x2; |
53 | 53 | private ImmutableDecimal $negTwo; |
54 | 54 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | } |
77 | 77 | }; |
78 | 78 | |
79 | - $bPart = new class() implements ContinuedFractionTermInterface{ |
|
79 | + $bPart = new class() implements ContinuedFractionTermInterface { |
|
80 | 80 | /** |
81 | 81 | * @param int $n |
82 | 82 | * @return ImmutableDecimal |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | } elseif ($this->isEqual(1)) { |
118 | 118 | $answer = Numbers::makeZero(); |
119 | 119 | } else { |
120 | - $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $scale + 2); |
|
120 | + $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $scale+2); |
|
121 | 121 | |
122 | 122 | $answer = $piDivTwo->subtract($z->arcsin($scale+2)); |
123 | 123 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | |
139 | 139 | $scale = $scale ?? $this->getScale(); |
140 | 140 | $abs = $this instanceof ImmutableDecimal ? $this->abs() : new ImmutableDecimal($this->absValue()); |
141 | - $intScale = $scale + 2; |
|
141 | + $intScale = $scale+2; |
|
142 | 142 | $terms = $abs->multiply($intScale+8)->asInt(); |
143 | 143 | $x = new ImmutableDecimal($this->getValue(NumberBase::Ten), $intScale); |
144 | 144 | $aPart = new class($x) implements ContinuedFractionTermInterface { |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | return Numbers::makeZero($this->intScale); |
188 | 188 | } |
189 | 189 | |
190 | - return SequenceProvider::nthOddNumber($n - 1)->truncateToScale($this->intScale); |
|
190 | + return SequenceProvider::nthOddNumber($n-1)->truncateToScale($this->intScale); |
|
191 | 191 | } |
192 | 192 | }; |
193 | 193 | |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | |
209 | 209 | $scale = $scale ?? $this->getScale(); |
210 | 210 | |
211 | - $piDivTwo = Numbers::makePi($scale + 2)->divide(2, $scale + 2); |
|
211 | + $piDivTwo = Numbers::makePi($scale+2)->divide(2, $scale+2); |
|
212 | 212 | |
213 | - $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $scale + 2); |
|
213 | + $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $scale+2); |
|
214 | 214 | |
215 | 215 | $arctan = $z->arctan($scale+2, false); |
216 | 216 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | { |
230 | 230 | |
231 | 231 | $scale = $scale ?? $this->getScale(); |
232 | - $intScale = $scale + 2; |
|
232 | + $intScale = $scale+2; |
|
233 | 233 | |
234 | 234 | $one = Numbers::makeOne($intScale); |
235 | 235 | $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this->getValue(NumberBase::Ten), $intScale); |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | $answer = SeriesProvider::generalizedContinuedFraction( |
288 | 288 | $aPart, |
289 | 289 | $bPart, |
290 | - $intScale * 2, |
|
290 | + $intScale*2, |
|
291 | 291 | $intScale, |
292 | 292 | SeriesProvider::SUM_MODE_SUB |
293 | 293 | ); |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | { |
306 | 306 | |
307 | 307 | $scale = $scale ?? $this->getScale(); |
308 | - $intScale = $scale + 2; |
|
308 | + $intScale = $scale+2; |
|
309 | 309 | |
310 | 310 | $one = Numbers::makeOne($intScale); |
311 | 311 | $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $intScale); |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | $answer = SeriesProvider::generalizedContinuedFraction( |
361 | 361 | $aPart, |
362 | 362 | $bPart, |
363 | - $intScale * 2, |
|
363 | + $intScale*2, |
|
364 | 364 | $intScale, |
365 | 365 | SeriesProvider::SUM_MODE_ALT_FIRST_ADD |
366 | 366 | ); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @param DecimalInterface $num |
17 | 17 | * @return string|false |
18 | 18 | */ |
19 | - protected function addGMP(DecimalInterface $num): string|false |
|
19 | + protected function addGMP(DecimalInterface $num): string | false |
|
20 | 20 | { |
21 | 21 | if (function_exists('gmp_add') && function_exists('gmp_strval') && $this->extensions) { |
22 | 22 | if ($this->isInt() && $num->isInt()) { |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param DecimalInterface $num |
34 | 34 | * @return string|false |
35 | 35 | */ |
36 | - protected function subtractGMP(DecimalInterface $num): string|false |
|
36 | + protected function subtractGMP(DecimalInterface $num): string | false |
|
37 | 37 | { |
38 | 38 | if (function_exists('gmp_sub') && function_exists('gmp_strval') && $this->extensions) { |
39 | 39 | if ($this->isInt() && $num->isInt()) { |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param DecimalInterface $num |
51 | 51 | * @return string|false |
52 | 52 | */ |
53 | - protected function multiplyGMP(DecimalInterface $num): string|false |
|
53 | + protected function multiplyGMP(DecimalInterface $num): string | false |
|
54 | 54 | { |
55 | 55 | if (function_exists('gmp_mul') && function_exists('gmp_strval') && $this->extensions) { |
56 | 56 | if ($this->isInt() && $num->isInt()) { |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param DecimalInterface $num |
68 | 68 | * @return string|false |
69 | 69 | */ |
70 | - protected function divideGMP(DecimalInterface $num): string|false |
|
70 | + protected function divideGMP(DecimalInterface $num): string | false |
|
71 | 71 | { |
72 | 72 | if (function_exists('gmp_div_qr') && function_exists('gmp_strval') && $this->extensions) { |
73 | 73 | if ($this->isInt() && $num->isInt()) { |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @param DecimalInterface $num |
92 | 92 | * @return string|false |
93 | 93 | */ |
94 | - protected function powGMP(DecimalInterface $num): string|false |
|
94 | + protected function powGMP(DecimalInterface $num): string | false |
|
95 | 95 | { |
96 | 96 | if (function_exists('gmp_pow') && function_exists('gmp_strval') && $this->extensions) { |
97 | 97 | if ($this->isInt() && $num->isInt() && $num->isPositive()) { |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | /** |
108 | 108 | * @return string|false |
109 | 109 | */ |
110 | - protected function sqrtGMP(): string|false |
|
110 | + protected function sqrtGMP(): string | false |
|
111 | 111 | { |
112 | 112 | if (function_exists('gmp_sqrtrem') && function_exists('gmp_strval') && $this->extensions) { |
113 | 113 | if ($this->isInt() && $this->isLessThan(PHP_INT_MAX) && $this->isGreaterThan(PHP_INT_MIN)) { |
@@ -24,7 +24,7 @@ |
||
24 | 24 | * @throws IntegrityConstraint |
25 | 25 | * @throws MissingPackage |
26 | 26 | */ |
27 | - public function continuousModulo(NumberInterface|string|int|float $mod): DecimalInterface |
|
27 | + public function continuousModulo(NumberInterface | string | int | float $mod): DecimalInterface |
|
28 | 28 | { |
29 | 29 | |
30 | 30 | $mod = Numbers::makeOrDont(Numbers::IMMUTABLE, $mod); |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | return self::$pi->truncateToScale($digits)->getValue(NumberBase::Ten); |
38 | 38 | } |
39 | 39 | |
40 | - $internalScale = ($digits*2) + 10; |
|
40 | + $internalScale = ($digits*2)+10; |
|
41 | 41 | |
42 | 42 | $C = Numbers::make(Numbers::IMMUTABLE, '10005', $internalScale)->setMode(CalcMode::Precision)->sqrt($internalScale)->multiply(426880); |
43 | 43 | $M = Numbers::make(Numbers::IMMUTABLE, '1', $internalScale)->setMode(CalcMode::Precision); |
44 | 44 | $L = Numbers::make(Numbers::IMMUTABLE, '13591409', $internalScale)->setMode(CalcMode::Precision); |
45 | 45 | $K = Numbers::make(Numbers::IMMUTABLE, '6', $internalScale)->setMode(CalcMode::Precision); |
46 | 46 | $X = Numbers::make(Numbers::IMMUTABLE, '1')->setMode(CalcMode::Precision); |
47 | - $sum = Numbers::make(Numbers::MUTABLE,'0', $internalScale + 2)->setMode(CalcMode::Precision); |
|
47 | + $sum = Numbers::make(Numbers::MUTABLE, '0', $internalScale+2)->setMode(CalcMode::Precision); |
|
48 | 48 | $termNum = 0; |
49 | 49 | $one = Numbers::makeOne($internalScale)->setMode(CalcMode::Precision); |
50 | 50 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | return self::$e->truncateToScale($digits)->getValue(NumberBase::Ten); |
97 | 97 | } |
98 | 98 | |
99 | - $internalScale = $digits + 3; |
|
99 | + $internalScale = $digits+3; |
|
100 | 100 | |
101 | 101 | $one = Numbers::makeOne($internalScale+5)->setMode(CalcMode::Precision); |
102 | 102 | $denominator = Numbers::make(Numbers::MUTABLE, '1', $internalScale)->setMode(CalcMode::Precision); |