@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @return ImmutableDecimal|MutableDecimal|NumberInterface|ImmutableDecimal[]|MutableDecimal[]|NumberInterface[] |
115 | 115 | * @throws IntegrityConstraint |
116 | 116 | */ |
117 | - public static function makeOrDont(string|object $type, mixed $value, ?int $scale = null, NumberBase $base = NumberBase::Ten) |
|
117 | + public static function makeOrDont(string | object $type, mixed $value, ?int $scale = null, NumberBase $base = NumberBase::Ten) |
|
118 | 118 | { |
119 | 119 | |
120 | 120 | if (is_object($value)) { |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | } |
237 | 237 | |
238 | 238 | if ($scale > 100) { |
239 | - $pi = self::make(self::IMMUTABLE, ConstantProvider::makePi($scale+2), $scale + 2); |
|
239 | + $pi = self::make(self::IMMUTABLE, ConstantProvider::makePi($scale+2), $scale+2); |
|
240 | 240 | /** @var ImmutableDecimal */ |
241 | 241 | return $pi->multiply(2)->truncateToScale($scale); |
242 | 242 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $total = strlen($fractional); |
148 | 148 | $fractional = ltrim($fractional, '0'); |
149 | 149 | |
150 | - return ($total - strlen($fractional)); |
|
150 | + return ($total-strlen($fractional)); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function numberOfTotalDigits(): int |
159 | 159 | { |
160 | - return $this->numberOfDecimalDigits() + $this->numberOfIntDigits(); |
|
160 | + return $this->numberOfDecimalDigits()+$this->numberOfIntDigits(); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | public function isFloat(): bool |
221 | 221 | { |
222 | 222 | |
223 | - return (bool)ArithmeticProvider::compare($this->getDecimalPart(), '0'); |
|
223 | + return (bool) ArithmeticProvider::compare($this->getDecimalPart(), '0'); |
|
224 | 224 | |
225 | 225 | } |
226 | 226 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | */ |
230 | 230 | public function asFloat(): float |
231 | 231 | { |
232 | - return (float)$this->asReal(); |
|
232 | + return (float) $this->asReal(); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $curVal = $this->getValue(NumberBase::Ten); |
54 | 54 | $calcVal = Numbers::make(Numbers::IMMUTABLE, 1); |
55 | 55 | |
56 | - for ($i = 1;$i <= $curVal;$i++) { |
|
56 | + for ($i = 1; $i <= $curVal; $i++) { |
|
57 | 57 | $calcVal = $calcVal->multiply($i); |
58 | 58 | } |
59 | 59 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | } |
248 | 248 | |
249 | 249 | if (function_exists('gmp_prob_prime') && $this->extensions) { |
250 | - return (bool)gmp_prob_prime($this->getValue(NumberBase::Ten), $certainty); |
|
250 | + return (bool) gmp_prob_prime($this->getValue(NumberBase::Ten), $certainty); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | $thisNum = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $this->getScale()); |
@@ -263,15 +263,15 @@ discard block |
||
263 | 263 | |
264 | 264 | $r = $r->subtract(1); |
265 | 265 | |
266 | - for ($i = 0;$i < $certainty;$i++) { |
|
266 | + for ($i = 0; $i < $certainty; $i++) { |
|
267 | 267 | $a = RandomProvider::randomInt(2, $s, RandomMode::Speed); |
268 | - $x = Numbers::make(Numbers::IMMUTABLE, (string)gmp_powm($a->getAsBaseTenRealNumber(), $d->getAsBaseTenRealNumber(), $thisNum->getAsBaseTenRealNumber())); |
|
268 | + $x = Numbers::make(Numbers::IMMUTABLE, (string) gmp_powm($a->getAsBaseTenRealNumber(), $d->getAsBaseTenRealNumber(), $thisNum->getAsBaseTenRealNumber())); |
|
269 | 269 | |
270 | 270 | if ($x->isEqual(1) || $x->isEqual($s)) { |
271 | 271 | continue; |
272 | 272 | } |
273 | 273 | |
274 | - for ($j = 0;$j < $r->asInt();$j++) { |
|
274 | + for ($j = 0; $j < $r->asInt(); $j++) { |
|
275 | 275 | $x = $x->pow(2)->modulo($thisNum); |
276 | 276 | if ($x->isEqual($s)) { |
277 | 277 | continue 2; |
@@ -177,7 +177,7 @@ |
||
177 | 177 | $prevDenominator = new ImmutableDecimal(0, $intScale); |
178 | 178 | $loop = 0; |
179 | 179 | |
180 | - for ($i = $terms;$i > 0;$i--) { |
|
180 | + for ($i = $terms; $i > 0; $i--) { |
|
181 | 181 | $loop++; |
182 | 182 | switch ($sumMode) { |
183 | 183 | case self::SUM_MODE_ADD: |
@@ -48,14 +48,14 @@ discard block |
||
48 | 48 | $e = Numbers::makeE($scale+$addScale); |
49 | 49 | $value = $e->pow($this); |
50 | 50 | } else { |
51 | - $intScale = ($this->numberOfIntDigits()) ? ($scale + 2) * $this->numberOfIntDigits() : ($scale + 2); |
|
52 | - $intScale = ($this->numberOfLeadingZeros()) ? $intScale * $this->numberOfLeadingZeros() : $intScale; |
|
51 | + $intScale = ($this->numberOfIntDigits()) ? ($scale+2)*$this->numberOfIntDigits() : ($scale+2); |
|
52 | + $intScale = ($this->numberOfLeadingZeros()) ? $intScale*$this->numberOfLeadingZeros() : $intScale; |
|
53 | 53 | $x = $this instanceof ImmutableDecimal ? $this : new ImmutableDecimal($this->getValue(NumberBase::Ten), $intScale); |
54 | 54 | $x2 = $x->pow(2); |
55 | 55 | $terms = $scale; |
56 | 56 | $six = new ImmutableDecimal(6, $intScale); |
57 | 57 | |
58 | - $aPart = new class($x2, $x) implements ContinuedFractionTermInterface{ |
|
58 | + $aPart = new class($x2, $x) implements ContinuedFractionTermInterface { |
|
59 | 59 | private ImmutableDecimal $x2; |
60 | 60 | private ImmutableDecimal $x; |
61 | 61 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | }; |
85 | 85 | |
86 | - $bPart = new class($x, $six, $intScale) implements ContinuedFractionTermInterface{ |
|
86 | + $bPart = new class($x, $six, $intScale) implements ContinuedFractionTermInterface { |
|
87 | 87 | private ImmutableDecimal $x; |
88 | 88 | private ImmutableDecimal $six; |
89 | 89 | private int $intScale; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | protected function lnScale(int $scale = null): string |
134 | 134 | { |
135 | 135 | $internalScale = $scale ?? $this->getScale(); |
136 | - $internalScale += 3 + $this->numberOfLeadingZeros(); |
|
136 | + $internalScale += 3+$this->numberOfLeadingZeros(); |
|
137 | 137 | |
138 | 138 | if (extension_loaded('decimal')) { |
139 | 139 | $decimalScale = max($internalScale*2, $this->numberOfTotalDigits()*2); |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | $answer = $adjustedNum; |
194 | 194 | |
195 | 195 | if ($exp2) { |
196 | - $answer = $answer->add(Numbers::makeNaturalLog2($internalScale + abs($exp2))->multiply($exp2)); |
|
196 | + $answer = $answer->add(Numbers::makeNaturalLog2($internalScale+abs($exp2))->multiply($exp2)); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | if ($exp1p1) { |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | |
39 | 39 | $thisNum = Numbers::make(Numbers::IMMUTABLE, $this->getValue(NumberBase::Ten), $modScale); |
40 | 40 | |
41 | - $twoPi = Numbers::make2Pi($modScale + 2); |
|
42 | - $pi = Numbers::makePi( $scale + 2 ); |
|
41 | + $twoPi = Numbers::make2Pi($modScale+2); |
|
42 | + $pi = Numbers::makePi($scale+2); |
|
43 | 43 | |
44 | 44 | if ($pi->truncate($scale)->isEqual($thisNum->truncate($scale)) || $twoPi->truncate($scale)->isEqual($thisNum->truncate($scale))) { |
45 | 45 | return '0'; |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | |
52 | 52 | $answer = SeriesProvider::maclaurinSeries( |
53 | 53 | $modulo, |
54 | - function ($n) use ($scale, $negOne, $one) { |
|
54 | + function($n) use ($scale, $negOne, $one) { |
|
55 | 55 | |
56 | - return $n % 2 ? $negOne : $one; |
|
56 | + return $n%2 ? $negOne : $one; |
|
57 | 57 | }, |
58 | - function ($n) { |
|
58 | + function($n) { |
|
59 | 59 | return SequenceProvider::nthOddNumber($n); |
60 | 60 | }, |
61 | - function ($n) { |
|
61 | + function($n) { |
|
62 | 62 | return SequenceProvider::nthOddNumber($n)->factorial(); |
63 | 63 | }, |
64 | 64 | 0, |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | |
89 | 89 | $thisNum = Numbers::make(Numbers::IMMUTABLE, $this->getValue(NumberBase::Ten), $modScale); |
90 | 90 | |
91 | - $twoPi = Numbers::make2Pi($modScale + 2); |
|
92 | - $pi = Numbers::makePi( $modScale + 2); |
|
91 | + $twoPi = Numbers::make2Pi($modScale+2); |
|
92 | + $pi = Numbers::makePi($modScale+2); |
|
93 | 93 | $piDivTwo = $pi->divide(2); |
94 | 94 | |
95 | 95 | if ($twoPi->truncate($scale)->isEqual($thisNum->truncate($scale))) { |
@@ -113,14 +113,14 @@ discard block |
||
113 | 113 | |
114 | 114 | $answer = SeriesProvider::maclaurinSeries( |
115 | 115 | $modulo, |
116 | - function ($n) use ($negOne, $one) { |
|
116 | + function($n) use ($negOne, $one) { |
|
117 | 117 | |
118 | - return $n % 2 ? $negOne : $one; |
|
118 | + return $n%2 ? $negOne : $one; |
|
119 | 119 | }, |
120 | - function ($n) use ($intScale) { |
|
120 | + function($n) use ($intScale) { |
|
121 | 121 | return SequenceProvider::nthEvenNumber($n, $intScale); |
122 | 122 | }, |
123 | - function ($n) use ($intScale) { |
|
123 | + function($n) use ($intScale) { |
|
124 | 124 | return SequenceProvider::nthEvenNumber($n, $intScale)->factorial(); |
125 | 125 | }, |
126 | 126 | 0, |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | protected function tanScale(int $scale = null): string |
140 | 140 | { |
141 | 141 | $scale = $scale ?? $this->getScale(); |
142 | - $intScale = $scale + 4; |
|
142 | + $intScale = $scale+4; |
|
143 | 143 | $intScale = $intScale+$this->numberOfIntDigits()+$this->numberOfLeadingZeros(); |
144 | 144 | |
145 | 145 | $thisNum = Numbers::make(Numbers::IMMUTABLE, $this->getValue(NumberBase::Ten), $intScale); |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | |
287 | 287 | if ($mod2Pi->isEqual(0)) { |
288 | 288 | return static::INFINITY; |
289 | - } elseif($modPi->isEqual(0)) { |
|
289 | + } elseif ($modPi->isEqual(0)) { |
|
290 | 290 | return static::NEG_INFINITY; |
291 | 291 | } |
292 | 292 |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $remainder = self::remainderCheck(); |
178 | 178 | |
179 | 179 | if ($early == 0) { |
180 | - return ($nextDigit % 2 == 0 && !$remainder) ? 0 : 1; |
|
180 | + return ($nextDigit%2 == 0 && !$remainder) ? 0 : 1; |
|
181 | 181 | } else { |
182 | 182 | return $early == 1 ? 1 : 0; |
183 | 183 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | $remainder = self::remainderCheck(); |
190 | 190 | |
191 | 191 | if ($early == 0) { |
192 | - return ($nextDigit % 2 == 1 && !$remainder) ? 0 : 1; |
|
192 | + return ($nextDigit%2 == 1 && !$remainder) ? 0 : 1; |
|
193 | 193 | } else { |
194 | 194 | return $early == 1 ? 1 : 0; |
195 | 195 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | |
240 | 240 | if ($early == 0 && !$remainder) { |
241 | 241 | $val = self::$alt; |
242 | - self::$alt = (int)!$val; |
|
242 | + self::$alt = (int) !$val; |
|
243 | 243 | |
244 | 244 | return $val; |
245 | 245 | } else { |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | $rangeMax = 9; |
258 | 258 | } else { |
259 | 259 | $remainder = substr($remainder, 0, 3); |
260 | - $target = (int)($digit.$remainder); |
|
260 | + $target = (int) ($digit.$remainder); |
|
261 | 261 | $rangeMin = 0; |
262 | - $rangeMax = (int)str_repeat('9', strlen($remainder) + 1); |
|
262 | + $rangeMax = (int) str_repeat('9', strlen($remainder)+1); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | $random = RandomProvider::randomInt($rangeMin, $rangeMax, RandomMode::Speed)->asInt(); |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | $roundedPartString = $currentPart ? $decimalPart : $wholePart; |
294 | 294 | $otherPart = $currentPart ? str_split($wholePart) : str_split($decimalPart); |
295 | 295 | $baseLength = $currentPart ? strlen($decimalPart)-1 : strlen($wholePart); |
296 | - $pos = $currentPart ? $places : $baseLength + $places; |
|
296 | + $pos = $currentPart ? $places : $baseLength+$places; |
|
297 | 297 | |
298 | 298 | if ($currentPart) { |
299 | 299 | $pos = ($absPlaces > $baseLength && $places < 0) ? $baseLength : $pos; |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | bool $currentPart |
355 | 355 | ): array |
356 | 356 | { |
357 | - $digit = (int)$roundedPart[$pos] + $carry; |
|
357 | + $digit = (int) $roundedPart[$pos]+$carry; |
|
358 | 358 | |
359 | 359 | if ($carry == 0 && $digit == 5) { |
360 | 360 | static::$remainder = substr($roundedPartString, $pos+1); |
@@ -364,12 +364,12 @@ discard block |
||
364 | 364 | |
365 | 365 | if ($pos == 0) { |
366 | 366 | if ($currentPart) { |
367 | - $nextDigit = (int)$otherPart[count($otherPart)-1]; |
|
367 | + $nextDigit = (int) $otherPart[count($otherPart)-1]; |
|
368 | 368 | } else { |
369 | 369 | $nextDigit = 0; |
370 | 370 | } |
371 | 371 | } else { |
372 | - $nextDigit = (int)$roundedPart[$pos-1]; |
|
372 | + $nextDigit = (int) $roundedPart[$pos-1]; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | return [$digit, $nextDigit]; |