public function testEquals()
 {
     $this->assertTrue(InfiniteDecimal::getPositiveInfinite()->equals(InfiniteDecimal::getPositiveInfinite()));
     $this->assertTrue(InfiniteDecimal::getNegativeInfinite()->equals(InfiniteDecimal::getNegativeInfinite()));
     $this->assertFalse(InfiniteDecimal::getPositiveInfinite()->equals(InfiniteDecimal::getNegativeInfinite()));
     $this->assertFalse(InfiniteDecimal::getNegativeInfinite()->equals(InfiniteDecimal::getPositiveInfinite()));
 }
 public function testInfiniteInfiniteDiv()
 {
     $pInf = InfiniteDecimal::getPositiveInfinite();
     $nInf = InfiniteDecimal::getNegativeInfinite();
     $catched = false;
     try {
         $pInf->div($pInf);
     } catch (\DomainException $e) {
         $catched = true;
     }
     $this->assertTrue($catched);
     $catched = false;
     try {
         $pInf->div($nInf);
     } catch (\DomainException $e) {
         $catched = true;
     }
     $this->assertTrue($catched);
     $catched = false;
     try {
         $nInf->div($pInf);
     } catch (\DomainException $e) {
         $catched = true;
     }
     $this->assertTrue($catched);
     $catched = false;
     try {
         $nInf->div($nInf);
     } catch (\DomainException $e) {
         $catched = true;
     }
     $this->assertTrue($catched);
 }
 public function testAsInteger()
 {
     $catched = false;
     try {
         InfiniteDecimal::getPositiveInfinite()->asInteger();
     } catch (InvalidCastException $e) {
         $catched = true;
     }
     $this->assertTrue($catched);
     $catched = false;
     try {
         InfiniteDecimal::getNegativeInfinite()->asInteger();
     } catch (InvalidCastException $e) {
         $catched = true;
     }
     $this->assertTrue($catched);
 }
Exemplo n.º 4
0
 /**
  * Returns the object's logarithm in base 10
  * @param  integer $scale
  * @return Decimal
  */
 public function log10($scale = null)
 {
     if ($this->isNegative()) {
         throw new \DomainException("Decimal can't handle logarithms of negative numbers (it's only for real numbers).");
     } elseif ($this->isZero()) {
         return InfiniteDecimal::getNegativeInfinite();
     }
     return self::fromString(self::innerLog10($this->value, $this->scale, $scale !== null ? $scale + 1 : $this->scale + 1), $scale);
 }
 /**
  * @expectedException \DomainException
  * @expectedExceptionMessage Decimal can't handle logarithms of negative numbers (it's only for real numbers).
  */
 public function testNegativeInfiniteLog10()
 {
     InfiniteDecimal::getNegativeInfinite()->log10();
 }
 public function testNegativeInfinite()
 {
     $this->assertTrue(InfiniteDecimal::getNegativeInfinite()->exp()->isZero());
 }
 /**
  * @expectedException \DomainException
  * @expectedExceptionMessage Cosecant function hasn't limit in the negative infinite.
  */
 public function testFiniteNegativeInfiniteCosec()
 {
     InfiniteDecimal::getNegativeInfinite()->cosec();
 }
 /**
  * @expectedException \DomainException
  * @expectedExceptionMessage Infinite elevated to zero is undefined.
  */
 public function testNegativeInfiniteZeroPower()
 {
     InfiniteDecimal::getNegativeInfinite()->pow(DecimalConstants::Zero());
 }
 /**
  * @expectedException \DomainException
  * @expectedExceptionMessage Sine function hasn't limit in the negative infinite.
  */
 public function testFiniteNegativeInfiniteSin()
 {
     InfiniteDecimal::getNegativeInfinite()->sin();
 }