/** * @param \Cubiche\Domain\System\Number $x * * @throws \DomainException * * @return static|null */ protected function divSpecialCases(Number $x) { if ($x->isZero()) { throw new \DomainException('Division by zero is not allowed.'); } if (($this->isZero() || $x->isInfinite()) && !$this->isInfinite()) { return static::fromNative(0); } return; }
/** * @param Number $x * * @throws \DomainException * * @return \Cubiche\Domain\System\DecimalInfinite */ protected function powSpecialCases(Number $x) { if ($x->isPositive()) { if ($this->isPositive()) { return $this; } if ($x->isInfinite()) { throw new \DomainException('The pow operation is not defined between "-INF" and "INF"'); } } elseif ($x->isNegative()) { return Decimal::fromNative(0); } return; }