| @@ 258-273 (lines=16) @@ | ||
| 255 | * |
|
| 256 | * @return \Cubiche\Domain\System\DecimalInfinite |
|
| 257 | */ |
|
| 258 | protected function powSpecialCases(Number $x) |
|
| 259 | { |
|
| 260 | if ($x->isPositive()) { |
|
| 261 | if ($this->isPositive()) { |
|
| 262 | return $this; |
|
| 263 | } |
|
| 264 | ||
| 265 | if ($x->isInfinite()) { |
|
| 266 | throw new \DomainException('The pow operation is not defined between "-INF" and "INF"'); |
|
| 267 | } |
|
| 268 | } elseif ($x->isNegative()) { |
|
| 269 | return Decimal::fromNative(0); |
|
| 270 | } |
|
| 271 | ||
| 272 | return; |
|
| 273 | } |
|
| 274 | ||
| 275 | /** |
|
| 276 | * {@inheritdoc} |
|
| @@ 214-225 (lines=12) @@ | ||
| 211 | * |
|
| 212 | * @return static|null |
|
| 213 | */ |
|
| 214 | protected function divSpecialCases(Number $x) |
|
| 215 | { |
|
| 216 | if ($x->isZero()) { |
|
| 217 | throw new \DomainException('Division by zero is not allowed.'); |
|
| 218 | } |
|
| 219 | ||
| 220 | if (($this->isZero() || $x->isInfinite()) && !$this->isInfinite()) { |
|
| 221 | return static::fromNative(0); |
|
| 222 | } |
|
| 223 | ||
| 224 | return; |
|
| 225 | } |
|
| 226 | ||
| 227 | /** |
|
| 228 | * @param \Cubiche\Domain\System\Integer $x |
|