/** * @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; }
public function testSetDefaultScale() { $this->if($scale = 8)->when(Decimal::setDefaultScale($scale))->then->variable(Decimal::defaultScale())->isEqualTo($scale)->if($invalidScale = 8.1)->then->exception(function () use($invalidScale) { Decimal::setDefaultScale($invalidScale); })->isInstanceOf(\InvalidArgumentException::class)->if($negativeScale = -2)->then->exception(function () use($negativeScale) { Decimal::setDefaultScale($negativeScale); })->isInstanceOf(\InvalidArgumentException::class); }