@@ -44,7 +44,7 @@ |
||
| 44 | 44 | public function asCartesian(?int $scale = null): CartesianCoordinate |
| 45 | 45 | { |
| 46 | 46 | $scale = $scale ?? 10; |
| 47 | - $intScale = $scale + 2; |
|
| 47 | + $intScale = $scale+2; |
|
| 48 | 48 | |
| 49 | 49 | if (is_null($this->cachedCartesian)) { |
| 50 | 50 | $x = $this->getAxis('rho')->multiply($this->getAxis('theta')->cos($intScale))->roundToScale($scale); |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | public function getDistanceFromOrigin(?int $scale = null): ImmutableDecimal |
| 77 | 77 | { |
| 78 | 78 | $scale = $scale ?? 10; |
| 79 | - $intScale = $scale + 2; |
|
| 79 | + $intScale = $scale+2; |
|
| 80 | 80 | |
| 81 | 81 | $x = 0; |
| 82 | 82 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | public function distanceTo(CoordinateInterface $coordinate, ?int $scale = null): ImmutableDecimal |
| 106 | 106 | { |
| 107 | 107 | $scale = $scale ?? 10; |
| 108 | - $intScale = $scale + 2; |
|
| 108 | + $intScale = $scale+2; |
|
| 109 | 109 | |
| 110 | 110 | if (!($coordinate instanceof CartesianCoordinate)) { |
| 111 | 111 | $coordinate = $coordinate->asCartesian(); |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | public function asPolar(?int $scale = null): PolarCoordinate |
| 228 | 228 | { |
| 229 | 229 | $scale = $scale ?? 10; |
| 230 | - $intScale = $scale + 3; |
|
| 230 | + $intScale = $scale+3; |
|
| 231 | 231 | |
| 232 | 232 | if ($this->numberOfDimensions() !== 2) { |
| 233 | 233 | throw new IncompatibleObjectState( |
@@ -113,7 +113,7 @@ |
||
| 113 | 113 | /** |
| 114 | 114 | * @return ImmutableDecimal|ImmutableFraction |
| 115 | 115 | */ |
| 116 | - abstract public function asReal(): ImmutableDecimal|ImmutableFraction; |
|
| 116 | + abstract public function asReal(): ImmutableDecimal | ImmutableFraction; |
|
| 117 | 117 | |
| 118 | 118 | /** |
| 119 | 119 | * @return string |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $scale = ($this->getScale() > $num->getScale()) ? $this->getScale() : $num->getScale(); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - $scale = $scale + $this->numberOfLeadingZeros() + $num->numberOfLeadingZeros(); |
|
| 71 | + $scale = $scale+$this->numberOfLeadingZeros()+$num->numberOfLeadingZeros(); |
|
| 72 | 72 | |
| 73 | 73 | return ArithmeticProvider::divide($this->getAsBaseTenRealNumber(), $num->getAsBaseTenRealNumber(), $scale+1); |
| 74 | 74 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | $scale = ($this->getScale() > $num->getScale()) ? $this->getScale() : $num->getScale(); |
| 86 | 86 | |
| 87 | - $scale += $this->numberOfDecimalDigits() + $num->numberOfDecimalDigits(); |
|
| 87 | + $scale += $this->numberOfDecimalDigits()+$num->numberOfDecimalDigits(); |
|
| 88 | 88 | |
| 89 | 89 | if ($this->isWhole() && $num->isPositive() && $num->isWhole() && $num->isLessThan(PHP_INT_MAX)) { |
| 90 | 90 | return gmp_strval(gmp_pow($this->getAsBaseTenRealNumber(), $num->asInt())); |
@@ -11,10 +11,10 @@ |
||
| 11 | 11 | { |
| 12 | 12 | |
| 13 | 13 | protected function setValue( |
| 14 | - ImmutableDecimal|ImmutableFraction $realPart, |
|
| 15 | - ImmutableDecimal|ImmutableFraction $imaginaryPart, |
|
| 14 | + ImmutableDecimal | ImmutableFraction $realPart, |
|
| 15 | + ImmutableDecimal | ImmutableFraction $imaginaryPart, |
|
| 16 | 16 | ?int $scale = null |
| 17 | - ): static|ImmutableComplexNumber |
|
| 17 | + ): static | ImmutableComplexNumber |
|
| 18 | 18 | { |
| 19 | 19 | $scale = $scale ?? $this->getScale(); |
| 20 | 20 | |
@@ -12,10 +12,10 @@ |
||
| 12 | 12 | { |
| 13 | 13 | |
| 14 | 14 | protected function setValue( |
| 15 | - ImmutableDecimal|ImmutableFraction $realPart, |
|
| 16 | - ImmutableDecimal|ImmutableFraction $imaginaryPart, |
|
| 15 | + ImmutableDecimal | ImmutableFraction $realPart, |
|
| 16 | + ImmutableDecimal | ImmutableFraction $imaginaryPart, |
|
| 17 | 17 | ?int $scale = null |
| 18 | - ): static|MutableComplexNumber |
|
| 18 | + ): static | MutableComplexNumber |
|
| 19 | 19 | { |
| 20 | 20 | $scale = $scale ?? $this->getScale(); |
| 21 | 21 | |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | { |
| 34 | 34 | |
| 35 | 35 | /** @var ImmutableDecimal|ImmutableFraction */ |
| 36 | - protected ImmutableDecimal|ImmutableFraction $realPart; |
|
| 36 | + protected ImmutableDecimal | ImmutableFraction $realPart; |
|
| 37 | 37 | /** @var ImmutableDecimal|ImmutableFraction */ |
| 38 | - protected ImmutableDecimal|ImmutableFraction $imaginaryPart; |
|
| 38 | + protected ImmutableDecimal | ImmutableFraction $imaginaryPart; |
|
| 39 | 39 | /** @var int */ |
| 40 | 40 | protected int $scale; |
| 41 | 41 | protected CartesianCoordinate $cachedCartesian; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | public function round( |
| 88 | 88 | int $decimals = 0, |
| 89 | 89 | ?RoundingMode $mode = null |
| 90 | - ): ImmutableComplexNumber|MutableComplexNumber|static |
|
| 90 | + ): ImmutableComplexNumber | MutableComplexNumber | static |
|
| 91 | 91 | { |
| 92 | 92 | $roundedReal = $this->realPart->round($decimals, $mode); |
| 93 | 93 | $roundedImaginary = $this->imaginaryPart->round($decimals, $mode); |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | public function roundToScale( |
| 104 | 104 | int $scale, |
| 105 | 105 | ?RoundingMode $mode = null |
| 106 | - ): ImmutableComplexNumber|MutableComplexNumber|static |
|
| 106 | + ): ImmutableComplexNumber | MutableComplexNumber | static |
|
| 107 | 107 | { |
| 108 | 108 | $roundedReal = $this->realPart->round($scale, $mode); |
| 109 | 109 | $roundedImaginary = $this->imaginaryPart->round($scale, $mode); |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | public function truncate( |
| 120 | 120 | int $decimals = 0 |
| 121 | - ): ImmutableComplexNumber|MutableComplexNumber|static |
|
| 121 | + ): ImmutableComplexNumber | MutableComplexNumber | static |
|
| 122 | 122 | { |
| 123 | 123 | $roundedReal = $this->realPart->truncate($decimals); |
| 124 | 124 | $roundedImaginary = $this->imaginaryPart->truncate($decimals); |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | public function truncateToScale( |
| 135 | 135 | int $scale |
| 136 | - ): ImmutableComplexNumber|MutableComplexNumber|static |
|
| 136 | + ): ImmutableComplexNumber | MutableComplexNumber | static |
|
| 137 | 137 | { |
| 138 | 138 | $roundedReal = $this->realPart->truncate($scale); |
| 139 | 139 | $roundedImaginary = $this->imaginaryPart->truncate($scale); |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | /** |
| 145 | 145 | * @return ImmutableComplexNumber|MutableComplexNumber|static |
| 146 | 146 | */ |
| 147 | - public function ceil(): ImmutableComplexNumber|MutableComplexNumber|static |
|
| 147 | + public function ceil(): ImmutableComplexNumber | MutableComplexNumber | static |
|
| 148 | 148 | { |
| 149 | 149 | return $this->round(0, RoundingMode::Ceil); |
| 150 | 150 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | /** |
| 153 | 153 | * @return ImmutableComplexNumber|MutableComplexNumber|static |
| 154 | 154 | */ |
| 155 | - public function floor(): ImmutableComplexNumber|MutableComplexNumber|static |
|
| 155 | + public function floor(): ImmutableComplexNumber | MutableComplexNumber | static |
|
| 156 | 156 | { |
| 157 | 157 | return $this->round(0, RoundingMode::Floor); |
| 158 | 158 | } |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | return false; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - public function asReal(): ImmutableDecimal|ImmutableFraction |
|
| 216 | + public function asReal(): ImmutableDecimal | ImmutableFraction |
|
| 217 | 217 | { |
| 218 | 218 | return (new ImmutableDecimal($this->getAsBaseTenRealNumber(), $this->getScale()))->setMode($this->getMode()); |
| 219 | 219 | } |
@@ -256,10 +256,10 @@ discard block |
||
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | abstract protected function setValue( |
| 259 | - ImmutableDecimal|ImmutableFraction $realPart, |
|
| 260 | - ImmutableDecimal|ImmutableFraction $imaginaryPart, |
|
| 259 | + ImmutableDecimal | ImmutableFraction $realPart, |
|
| 260 | + ImmutableDecimal | ImmutableFraction $imaginaryPart, |
|
| 261 | 261 | ?int $scale = null |
| 262 | - ): static|ImmutableComplexNumber|MutableComplexNumber; |
|
| 262 | + ): static | ImmutableComplexNumber | MutableComplexNumber; |
|
| 263 | 263 | |
| 264 | 264 | public static function makeFromArray(array $number, $scale = null, NumberBase $base = NumberBase::Ten): ComplexNumber |
| 265 | 265 | { |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | * @throws IntegrityConstraint |
| 43 | 43 | */ |
| 44 | 44 | public function add( |
| 45 | - string|int|float|Decimal|Fraction|ComplexNumber $num |
|
| 46 | - ): MutableDecimal|ImmutableDecimal|MutableComplexNumber|ImmutableComplexNumber|MutableFraction|ImmutableFraction|static |
|
| 45 | + string | int | float | Decimal | Fraction | ComplexNumber $num |
|
| 46 | + ): MutableDecimal | ImmutableDecimal | MutableComplexNumber | ImmutableComplexNumber | MutableFraction | ImmutableFraction | static |
|
| 47 | 47 | { |
| 48 | 48 | |
| 49 | 49 | $scale = $this->getScale(); |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | * @return MutableDecimal|ImmutableDecimal|MutableComplexNumber|ImmutableComplexNumber|MutableFraction|ImmutableFraction|static |
| 76 | 76 | */ |
| 77 | 77 | public function subtract( |
| 78 | - string|int|float|Decimal|Fraction|ComplexNumber $num |
|
| 79 | - ): MutableDecimal|ImmutableDecimal|MutableComplexNumber|ImmutableComplexNumber|MutableFraction|ImmutableFraction|static |
|
| 78 | + string | int | float | Decimal | Fraction | ComplexNumber $num |
|
| 79 | + ): MutableDecimal | ImmutableDecimal | MutableComplexNumber | ImmutableComplexNumber | MutableFraction | ImmutableFraction | static |
|
| 80 | 80 | { |
| 81 | 81 | $scale = $this->getScale(); |
| 82 | 82 | |
@@ -107,8 +107,8 @@ discard block |
||
| 107 | 107 | * @throws IntegrityConstraint |
| 108 | 108 | */ |
| 109 | 109 | public function multiply( |
| 110 | - string|int|float|Decimal|Fraction|ComplexNumber $num |
|
| 111 | - ): MutableDecimal|ImmutableDecimal|MutableComplexNumber|ImmutableComplexNumber|MutableFraction|ImmutableFraction|static |
|
| 110 | + string | int | float | Decimal | Fraction | ComplexNumber $num |
|
| 111 | + ): MutableDecimal | ImmutableDecimal | MutableComplexNumber | ImmutableComplexNumber | MutableFraction | ImmutableFraction | static |
|
| 112 | 112 | { |
| 113 | 113 | $scale = $this->getScale(); |
| 114 | 114 | |
@@ -161,9 +161,9 @@ discard block |
||
| 161 | 161 | * @throws IncompatibleObjectState |
| 162 | 162 | */ |
| 163 | 163 | public function divide( |
| 164 | - string|int|float|Decimal|Fraction|ComplexNumber $num, |
|
| 164 | + string | int | float | Decimal | Fraction | ComplexNumber $num, |
|
| 165 | 165 | ?int $scale = null |
| 166 | - ): MutableDecimal|ImmutableDecimal|MutableComplexNumber|ImmutableComplexNumber|MutableFraction|ImmutableFraction|static |
|
| 166 | + ): MutableDecimal | ImmutableDecimal | MutableComplexNumber | ImmutableComplexNumber | MutableFraction | ImmutableFraction | static |
|
| 167 | 167 | { |
| 168 | 168 | |
| 169 | 169 | $scale = $scale ?? $this->getScale(); |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | [$thatRealPart, $thatImaginaryPart] = self::partSelector($thatNum, $thisNum, 1, $this->getMode()); |
| 174 | 174 | |
| 175 | 175 | if ($thatNum->isComplex()) { |
| 176 | - $intScale = $scale + 2; |
|
| 176 | + $intScale = $scale+2; |
|
| 177 | 177 | $denominator = $thatRealPart->roundToScale($intScale)->pow(2)->add($thatImaginaryPart->asReal()->roundToScale($intScale)->pow(2)); |
| 178 | 178 | |
| 179 | 179 | $partA = $thisRealPart->roundToScale($intScale)->multiply($thatRealPart->roundToScale($intScale)) |
@@ -214,9 +214,9 @@ discard block |
||
| 214 | 214 | * @throws IntegrityConstraint |
| 215 | 215 | */ |
| 216 | 216 | public function pow( |
| 217 | - string|int|float|Decimal|Fraction|ComplexNumber $num, |
|
| 217 | + string | int | float | Decimal | Fraction | ComplexNumber $num, |
|
| 218 | 218 | ?int $scale = null |
| 219 | - ): MutableDecimal|ImmutableDecimal|MutableComplexNumber|ImmutableComplexNumber|MutableFraction|ImmutableFraction|static |
|
| 219 | + ): MutableDecimal | ImmutableDecimal | MutableComplexNumber | ImmutableComplexNumber | MutableFraction | ImmutableFraction | static |
|
| 220 | 220 | { |
| 221 | 221 | $scale = $scale ?? $this->getScale(); |
| 222 | 222 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | if ($thatNum->isReal() && $thatNum->isNatural() && $thatNum->isPositive()) { |
| 230 | 230 | $newValue = clone $this; |
| 231 | 231 | |
| 232 | - for ($i=0;$thatNum->isGreaterThan($i);$i++) { |
|
| 232 | + for ($i = 0;$thatNum->isGreaterThan($i);$i++) { |
|
| 233 | 233 | $newValue = $newValue->multiply($this); |
| 234 | 234 | } |
| 235 | 235 | |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | */ |
| 276 | 276 | public function sqrt( |
| 277 | 277 | ?int $scale = null |
| 278 | - ): MutableDecimal|ImmutableDecimal|MutableComplexNumber|ImmutableComplexNumber|MutableFraction|ImmutableFraction|static |
|
| 278 | + ): MutableDecimal | ImmutableDecimal | MutableComplexNumber | ImmutableComplexNumber | MutableFraction | ImmutableFraction | static |
|
| 279 | 279 | { |
| 280 | 280 | |
| 281 | 281 | $scale = $scale ?? $this->getScale(); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | ); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - $internalScale = $scale + 2; |
|
| 63 | + $internalScale = $scale+2; |
|
| 64 | 64 | |
| 65 | 65 | $e = Numbers::makeE($internalScale); |
| 66 | 66 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | ); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - $internalScale = $scale + 2; |
|
| 99 | + $internalScale = $scale+2; |
|
| 100 | 100 | |
| 101 | 101 | $e = Numbers::makeE($internalScale); |
| 102 | 102 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | ); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - $internalScale = $scale + 2; |
|
| 138 | + $internalScale = $scale+2; |
|
| 139 | 139 | |
| 140 | 140 | /** @var ImmutableDecimal $rangePdf */ |
| 141 | 141 | $rangePdf = |