@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | $scale = $scale ?? $this->getScale(); |
35 | 35 | $modScale = ($scale > $this->getScale()) ? $scale : $this->getScale(); |
36 | 36 | |
37 | - $twoPi = Numbers::make2Pi($modScale * 2); |
|
38 | - $pi = Numbers::makePi( $scale + 2 ); |
|
37 | + $twoPi = Numbers::make2Pi($modScale*2); |
|
38 | + $pi = Numbers::makePi($scale+2); |
|
39 | 39 | |
40 | 40 | if ($pi->truncate($scale)->isEqual($this) || $twoPi->truncate($scale)->isEqual($this)) { |
41 | 41 | return '0'; |
@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | |
48 | 48 | $answer = SeriesProvider::maclaurinSeries( |
49 | 49 | $modulo, |
50 | - function ($n) use ($scale, $negOne, $one) { |
|
50 | + function($n) use ($scale, $negOne, $one) { |
|
51 | 51 | |
52 | - return $n % 2 ? $negOne : $one; |
|
52 | + return $n%2 ? $negOne : $one; |
|
53 | 53 | }, |
54 | - function ($n) { |
|
54 | + function($n) { |
|
55 | 55 | return SequenceProvider::nthOddNumber($n); |
56 | 56 | }, |
57 | - function ($n) { |
|
57 | + function($n) { |
|
58 | 58 | return SequenceProvider::nthOddNumber($n)->factorial(); |
59 | 59 | }, |
60 | 60 | 0, |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | $scale = $scale ?? $this->getScale(); |
81 | 81 | $modScale = ($scale > $this->getScale()) ? $scale : $this->getScale(); |
82 | 82 | |
83 | - $twoPi = Numbers::make2Pi($modScale * 2); |
|
84 | - $pi = Numbers::makePi( $scale + 2 ); |
|
83 | + $twoPi = Numbers::make2Pi($modScale*2); |
|
84 | + $pi = Numbers::makePi($scale+2); |
|
85 | 85 | |
86 | 86 | if ($twoPi->truncate($scale)->isEqual($this)) { |
87 | 87 | return '1'; |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | |
98 | 98 | $answer = SeriesProvider::maclaurinSeries( |
99 | 99 | $modulo, |
100 | - function ($n) use ($scale, $negOne, $one) { |
|
100 | + function($n) use ($scale, $negOne, $one) { |
|
101 | 101 | |
102 | - return $n % 2 ? $negOne : $one; |
|
102 | + return $n%2 ? $negOne : $one; |
|
103 | 103 | }, |
104 | - function ($n) { |
|
104 | + function($n) { |
|
105 | 105 | return SequenceProvider::nthEvenNumber($n); |
106 | 106 | }, |
107 | - function ($n) { |
|
107 | + function($n) { |
|
108 | 108 | return SequenceProvider::nthEvenNumber($n)->factorial(); |
109 | 109 | }, |
110 | 110 | 0, |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | protected function tanScale(int $scale = null): string |
124 | 124 | { |
125 | 125 | $scale = $scale ?? $this->getScale(); |
126 | - $intScale = $scale + 2; |
|
126 | + $intScale = $scale+2; |
|
127 | 127 | |
128 | 128 | $pi = Numbers::makePi($intScale); |
129 | 129 | $piDivTwo = Numbers::makePi($intScale)->divide(2); |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | |
267 | 267 | if ($mod2Pi->isEqual(0)) { |
268 | 268 | return static::INFINITY; |
269 | - } elseif($modPi->isEqual(0)) { |
|
269 | + } elseif ($modPi->isEqual(0)) { |
|
270 | 270 | return static::NEG_INFINITY; |
271 | 271 | } |
272 | 272 |
@@ -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 (function_exists('gmp_add') && function_exists('gmp_strval')) { |
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')) { |
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')) { |
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')) { |
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')) { |
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')) { |
113 | 113 | if ($this->isInt() && $this->isLessThan(PHP_INT_MAX) && $this->isGreaterThan(PHP_INT_MIN)) { |
@@ -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,74 +24,74 @@ 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; |
|
33 | - return (string)$value; |
|
32 | + $value = $left+$right; |
|
33 | + return (string) $value; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
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; |
|
46 | - return (string)$value; |
|
45 | + $value = $left-$right; |
|
46 | + return (string) $value; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
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; |
|
59 | - return (string)$value; |
|
58 | + $value = $left*$right; |
|
59 | + return (string) $value; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
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; |
|
72 | - return (string)$value; |
|
71 | + $value = $left/$right; |
|
72 | + return (string) $value; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
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); |
83 | 83 | |
84 | 84 | $value = pow($left, $right); |
85 | - return (string)$value; |
|
85 | + return (string) $value; |
|
86 | 86 | } |
87 | 87 | |
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->asFloat()); |
94 | - return (string)$value; |
|
94 | + return (string) $value; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | } |
98 | 98 | \ No newline at end of file |
@@ -86,7 +86,7 @@ |
||
86 | 86 | if (!$num->isWhole()) { |
87 | 87 | $scale += 2; |
88 | 88 | $exponent = $num->multiply($thisNum->ln($scale)); |
89 | - return $exponent->exp($scale)->truncateToScale($scale - 2)->getValue(NumberBase::Ten); |
|
89 | + return $exponent->exp($scale)->truncateToScale($scale-2)->getValue(NumberBase::Ten); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | return ArithmeticProvider::pow($this->asReal(), $num->asReal(), $scale); |
@@ -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')) { |
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,13 +263,13 @@ 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 | 268 | $x = $a->pow($d)->modulo($thisNum); |
269 | 269 | if ($x->isEqual(1) || $x->isEqual($s)) { |
270 | 270 | continue; |
271 | 271 | } |
272 | - for ($j = 0;$j < $r->asInt();$j++) { |
|
272 | + for ($j = 0; $j < $r->asInt(); $j++) { |
|
273 | 273 | $x = $x->pow(2)->modulo($thisNum); |
274 | 274 | if ($x->isEqual($s)) { |
275 | 275 | continue 2; |
@@ -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 |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | $this->base = $base; |
50 | 50 | |
51 | - $value = $value instanceof NumberInterface ? $value->getValue(NumberBase::Ten) : (string)$value; |
|
51 | + $value = $value instanceof NumberInterface ? $value->getValue(NumberBase::Ten) : (string) $value; |
|
52 | 52 | |
53 | 53 | if (str_contains($value, 'i')) { |
54 | 54 | $this->imaginary = true; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $this->scale = ($scale > strlen($this->getDecimalPart())) ? $scale : strlen($this->getDecimalPart()); |
76 | 76 | } else { |
77 | 77 | $checkVal = $this->getDecimalPart(); |
78 | - $checkVal = trim($checkVal,'0'); |
|
78 | + $checkVal = trim($checkVal, '0'); |
|
79 | 79 | |
80 | 80 | if (strlen($checkVal) > 0) { |
81 | 81 | $this->scale = (strlen($this->getDecimalPart()) > 10) ? strlen($this->getDecimalPart()) : 10; |
@@ -120,14 +120,14 @@ discard block |
||
120 | 120 | if ($exp > 0) { |
121 | 121 | $exp -= strlen($right); |
122 | 122 | if ($exp >= 0) { |
123 | - $right = str_pad($right, $exp - 1, '0').'.0'; |
|
123 | + $right = str_pad($right, $exp-1, '0').'.0'; |
|
124 | 124 | } else { |
125 | - $right = substr($right, 0, strlen($right) + $exp).'.'.substr($right, strlen($right) + $exp + 1); |
|
125 | + $right = substr($right, 0, strlen($right)+$exp).'.'.substr($right, strlen($right)+$exp+1); |
|
126 | 126 | } |
127 | 127 | } else { |
128 | 128 | $exp += strlen($left); |
129 | 129 | if ($exp >= 0) { |
130 | - $left = substr($left, 0, $exp).'.'.substr($left, $exp + 1); |
|
130 | + $left = substr($left, 0, $exp).'.'.substr($left, $exp+1); |
|
131 | 131 | } else { |
132 | 132 | $left = '0.'.str_pad($left, $exp, '0', STR_PAD_LEFT); |
133 | 133 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @param NumberBase $base |
278 | 278 | * @return DecimalInterface|NumberInterface |
279 | 279 | */ |
280 | - public function setBase(NumberBase $base): DecimalInterface|NumberInterface |
|
280 | + public function setBase(NumberBase $base): DecimalInterface | NumberInterface |
|
281 | 281 | { |
282 | 282 | $this->base = $base; |
283 | 283 | |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * |
290 | 290 | * @return DecimalInterface|NumberInterface |
291 | 291 | */ |
292 | - public function abs(): DecimalInterface|NumberInterface |
|
292 | + public function abs(): DecimalInterface | NumberInterface |
|
293 | 293 | { |
294 | 294 | $newValue = $this->absValue(); |
295 | 295 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @param DecimalInterface $num |
301 | 301 | * @return float|int |
302 | 302 | */ |
303 | - protected static function translateToNative(DecimalInterface $num): float|int |
|
303 | + protected static function translateToNative(DecimalInterface $num): float | int |
|
304 | 304 | { |
305 | 305 | return ($num->isInt() ? $num->asInt() : $num->asFloat()); |
306 | 306 | } |
@@ -359,6 +359,6 @@ discard block |
||
359 | 359 | * @param NumberInterface|string|int|float $mod |
360 | 360 | * @return DecimalInterface |
361 | 361 | */ |
362 | - abstract public function continuousModulo(NumberInterface|string|int|float $mod): DecimalInterface; |
|
362 | + abstract public function continuousModulo(NumberInterface | string | int | float $mod): DecimalInterface; |
|
363 | 363 | |
364 | 364 | } |
365 | 365 | \ No newline at end of file |
@@ -23,7 +23,7 @@ |
||
23 | 23 | * @throws IntegrityConstraint |
24 | 24 | * @throws MissingPackage |
25 | 25 | */ |
26 | - public function continuousModulo(NumberInterface|string|int|float $mod): DecimalInterface |
|
26 | + public function continuousModulo(NumberInterface | string | int | float $mod): DecimalInterface |
|
27 | 27 | { |
28 | 28 | |
29 | 29 | if (is_object($mod) && method_exists($mod, 'getScale')) { |