@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | protected function helperArctanGCF(ImmutableDecimal $num, ?int $scale): ImmutableDecimal |
27 | 27 | { |
28 | 28 | $scale = $scale ?? $this->getScale(); |
29 | - $intScale = $scale + 2; |
|
30 | - $terms = $intScale + 2; |
|
29 | + $intScale = $scale+2; |
|
30 | + $terms = $intScale+2; |
|
31 | 31 | $x = new ImmutableDecimal($num, $intScale); |
32 | 32 | $aPart = new class($x) implements ContinuedFractionTermInterface { |
33 | 33 | private ImmutableDecimal $x; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | return Numbers::makeZero($this->intScale); |
76 | 76 | } |
77 | 77 | |
78 | - return SequenceProvider::nthOddNumber($n - 1); |
|
78 | + return SequenceProvider::nthOddNumber($n-1); |
|
79 | 79 | } |
80 | 80 | }; |
81 | 81 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $x2 = $x->pow(2); |
97 | 97 | $one = new ImmutableDecimal(1, $scale); |
98 | 98 | |
99 | - $aPart = new class($x2, $scale) implements ContinuedFractionTermInterface{ |
|
99 | + $aPart = new class($x2, $scale) implements ContinuedFractionTermInterface { |
|
100 | 100 | private ImmutableDecimal $x2; |
101 | 101 | private ImmutableDecimal $negTwo; |
102 | 102 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | }; |
126 | 126 | |
127 | - $bPart = new class() implements ContinuedFractionTermInterface{ |
|
127 | + $bPart = new class() implements ContinuedFractionTermInterface { |
|
128 | 128 | /** |
129 | 129 | * @param int $n |
130 | 130 | * @return ImmutableDecimal |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | } elseif ($this->isEqual(0)) { |
44 | 44 | $answer = Numbers::makeZero(); |
45 | 45 | } else { |
46 | - $intScale = $scale + 2; |
|
46 | + $intScale = $scale+2; |
|
47 | 47 | $num = new ImmutableDecimal($this->getValue(NumberBase::Ten), $intScale); |
48 | 48 | |
49 | 49 | $answer = $this->helperArcsinGCF($num, $intScale); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | } elseif ($this->isEqual(1)) { |
74 | 74 | $answer = Numbers::makeZero(); |
75 | 75 | } else { |
76 | - $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $scale + 2); |
|
76 | + $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $scale+2); |
|
77 | 77 | |
78 | 78 | $answer = $piDivTwo->subtract($z->arcsin($scale+2)); |
79 | 79 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | protected function arctanScale(int $scale = null): string |
92 | 92 | { |
93 | - $intScale = ($scale ?? $this->getScale()) + 2; |
|
93 | + $intScale = ($scale ?? $this->getScale())+2; |
|
94 | 94 | |
95 | 95 | $thisNum = Numbers::makeOrDont(Numbers::IMMUTABLE, $this->absValue()); |
96 | 96 | |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | |
128 | 128 | $scale = $scale ?? $this->getScale(); |
129 | 129 | |
130 | - $piDivTwo = Numbers::makePi($scale + 2)->divide(2, $scale + 2); |
|
130 | + $piDivTwo = Numbers::makePi($scale+2)->divide(2, $scale+2); |
|
131 | 131 | |
132 | - $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this->absValue(), $scale + 2); |
|
132 | + $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this->absValue(), $scale+2); |
|
133 | 133 | |
134 | 134 | $arctan = $z->arctan($scale+2, false); |
135 | 135 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | { |
153 | 153 | |
154 | 154 | $scale = $scale ?? $this->getScale(); |
155 | - $intScale = $scale + 2; |
|
155 | + $intScale = $scale+2; |
|
156 | 156 | |
157 | 157 | $one = Numbers::makeOne($intScale); |
158 | 158 | $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this->absValue(), $intScale); |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $answer = SeriesProvider::generalizedContinuedFraction( |
209 | 209 | $aPart, |
210 | 210 | $bPart, |
211 | - $intScale * 2, |
|
211 | + $intScale*2, |
|
212 | 212 | $intScale, |
213 | 213 | SeriesProvider::SUM_MODE_SUB |
214 | 214 | ); |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | { |
232 | 232 | |
233 | 233 | $scale = $scale ?? $this->getScale(); |
234 | - $intScale = $scale + 2; |
|
234 | + $intScale = $scale+2; |
|
235 | 235 | |
236 | 236 | $one = Numbers::makeOne($intScale); |
237 | 237 | $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $intScale); |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | $answer = SeriesProvider::generalizedContinuedFraction( |
287 | 287 | $aPart, |
288 | 288 | $bPart, |
289 | - $intScale * 2, |
|
289 | + $intScale*2, |
|
290 | 290 | $intScale, |
291 | 291 | SeriesProvider::SUM_MODE_ALT_FIRST_ADD |
292 | 292 | ); |
@@ -15,7 +15,7 @@ |
||
15 | 15 | * @param DecimalInterface $num |
16 | 16 | * @return float|int |
17 | 17 | */ |
18 | - abstract protected static function translateToNative(DecimalInterface $num): float|int; |
|
18 | + abstract protected static function translateToNative(DecimalInterface $num): float | int; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @return float |
@@ -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 |
@@ -41,7 +41,7 @@ |
||
41 | 41 | * @return bool |
42 | 42 | * @throws IntegrityConstraint |
43 | 43 | */ |
44 | - public function isEqual(NumberInterface|int|string|float $value): bool |
|
44 | + public function isEqual(NumberInterface | int | string | float $value): bool |
|
45 | 45 | { |
46 | 46 | |
47 | 47 | $check = $this->checkComparisonTraitAndInterface(); |
@@ -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 ($this->isInt() && $num->isInt()) { |
22 | 22 | $result = gmp_add($this->getAsBaseTenRealNumber(), $num->getAsBaseTenRealNumber()); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param DecimalInterface $num |
32 | 32 | * @return string|false |
33 | 33 | */ |
34 | - protected function subtractGMP(DecimalInterface $num): string|false |
|
34 | + protected function subtractGMP(DecimalInterface $num): string | false |
|
35 | 35 | { |
36 | 36 | if ($this->isInt() && $num->isInt()) { |
37 | 37 | $result = gmp_sub($this->getAsBaseTenRealNumber(), $num->getAsBaseTenRealNumber()); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param DecimalInterface $num |
47 | 47 | * @return string|false |
48 | 48 | */ |
49 | - protected function multiplyGMP(DecimalInterface $num): string|false |
|
49 | + protected function multiplyGMP(DecimalInterface $num): string | false |
|
50 | 50 | { |
51 | 51 | if ($this->isInt() && $num->isInt()) { |
52 | 52 | $result = gmp_mul($this->getAsBaseTenRealNumber(), $num->getAsBaseTenRealNumber()); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @param DecimalInterface $num |
62 | 62 | * @return string|false |
63 | 63 | */ |
64 | - protected function divideGMP(DecimalInterface $num): string|false |
|
64 | + protected function divideGMP(DecimalInterface $num): string | false |
|
65 | 65 | { |
66 | 66 | if ($this->isInt() && $num->isInt()) { |
67 | 67 | $result = gmp_div_qr($this->getAsBaseTenRealNumber(), $num->getAsBaseTenRealNumber()); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param DecimalInterface $num |
79 | 79 | * @return string|false |
80 | 80 | */ |
81 | - protected function powGMP(DecimalInterface $num): string|false |
|
81 | + protected function powGMP(DecimalInterface $num): string | false |
|
82 | 82 | { |
83 | 83 | if ($this->isInt() && $num->isInt() && $num->isPositive()) { |
84 | 84 | $result = gmp_pow($this->getAsBaseTenRealNumber(), $num->getAsBaseTenRealNumber()); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | /** |
93 | 93 | * @return string|false |
94 | 94 | */ |
95 | - protected function sqrtGMP(): string|false |
|
95 | + protected function sqrtGMP(): string | false |
|
96 | 96 | { |
97 | 97 | if ($this->isInt()) { |
98 | 98 | $result = gmp_sqrtrem($this->getAsBaseTenRealNumber()); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @param DecimalInterface $num |
16 | 16 | * @return int|float |
17 | 17 | */ |
18 | - protected static function translateToNative(DecimalInterface $num): int|float |
|
18 | + protected static function translateToNative(DecimalInterface $num): int | float |
|
19 | 19 | { |
20 | 20 | return ($num->isInt() ? $num->asInt() : $num->asFloat()); |
21 | 21 | } |
@@ -24,12 +24,12 @@ discard block |
||
24 | 24 | * @param DecimalInterface $num |
25 | 25 | * @return int|float |
26 | 26 | */ |
27 | - protected function addNative(DecimalInterface $num): int|float |
|
27 | + protected function addNative(DecimalInterface $num): int | float |
|
28 | 28 | { |
29 | 29 | $left = self::translateToNative($this); |
30 | 30 | $right = self::translateToNative($num); |
31 | 31 | |
32 | - $value = $left + $right; |
|
32 | + $value = $left+$right; |
|
33 | 33 | return (string)$value; |
34 | 34 | } |
35 | 35 | |
@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | * @param DecimalInterface $num |
38 | 38 | * @return int|float |
39 | 39 | */ |
40 | - protected function subtractNative(DecimalInterface $num): int|float |
|
40 | + protected function subtractNative(DecimalInterface $num): int | float |
|
41 | 41 | { |
42 | 42 | $left = self::translateToNative($this); |
43 | 43 | $right = self::translateToNative($num); |
44 | 44 | |
45 | - $value = $left - $right; |
|
45 | + $value = $left-$right; |
|
46 | 46 | return (string)$value; |
47 | 47 | } |
48 | 48 | |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | * @param DecimalInterface $num |
51 | 51 | * @return int|float |
52 | 52 | */ |
53 | - protected function multiplyNative(DecimalInterface $num): int|float |
|
53 | + protected function multiplyNative(DecimalInterface $num): int | float |
|
54 | 54 | { |
55 | 55 | $left = self::translateToNative($this); |
56 | 56 | $right = self::translateToNative($num); |
57 | 57 | |
58 | - $value = $left * $right; |
|
58 | + $value = $left*$right; |
|
59 | 59 | return (string)$value; |
60 | 60 | } |
61 | 61 | |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | * @param DecimalInterface $num |
64 | 64 | * @return int|float |
65 | 65 | */ |
66 | - protected function divideNative(DecimalInterface $num): int|float |
|
66 | + protected function divideNative(DecimalInterface $num): int | float |
|
67 | 67 | { |
68 | 68 | $left = self::translateToNative($this); |
69 | 69 | $right = self::translateToNative($num); |
70 | 70 | |
71 | - $value = $left / $right; |
|
71 | + $value = $left/$right; |
|
72 | 72 | return (string)$value; |
73 | 73 | } |
74 | 74 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @param DecimalInterface $num |
77 | 77 | * @return int|float |
78 | 78 | */ |
79 | - protected function powNative(DecimalInterface $num): int|float |
|
79 | + protected function powNative(DecimalInterface $num): int | float |
|
80 | 80 | { |
81 | 81 | $left = self::translateToNative($this); |
82 | 82 | $right = self::translateToNative($num); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | /** |
89 | 89 | * @return int|float |
90 | 90 | */ |
91 | - protected function sqrtNative(): int|float |
|
91 | + protected function sqrtNative(): int | float |
|
92 | 92 | { |
93 | 93 | $value = sqrt($this->abs()->asFloat()); |
94 | 94 | return (string)$value; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function sort(): NumberCollectionInterface |
181 | 181 | { |
182 | - $this->getCollection()->sort(function($left, $right){ |
|
182 | + $this->getCollection()->sort(function($left, $right) { |
|
183 | 183 | return ArithmeticProvider::compare($left->getAsBaseTenRealNumber(), $right->getAsBaseTenRealNumber()); |
184 | 184 | }); |
185 | 185 | |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | */ |
313 | 313 | public function getRandom(): NumberInterface |
314 | 314 | { |
315 | - $maxKey = $this->getCollection()->count() - 1; |
|
315 | + $maxKey = $this->getCollection()->count()-1; |
|
316 | 316 | |
317 | 317 | $key = RandomProvider::randomInt(0, $maxKey, RandomMode::Speed)->asInt(); |
318 | 318 |
@@ -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); |