isPositive() public method

public isPositive ( ) : boolean
return boolean
コード例 #1
0
ファイル: Money.php プロジェクト: coolms/money
 /**
  * Checks if the value represented by this object is positive
  *
  * @return bool
  */
 public function isPositive()
 {
     return $this->amount->isPositive();
 }
コード例 #2
0
 /**
  * Indicates if the passed parameter has the same sign as the method's bound object.
  *
  * @param Decimal $b
  * @return bool
  */
 public function hasSameSign(Decimal $b)
 {
     return $this->isPositive() && $b->isPositive() || $this->isNegative() && $b->isNegative();
 }
コード例 #3
0
 /**
  * Powers this value to $b
  *
  * @param  Decimal  $b      exponent
  * @param  integer  $scale
  * @return Decimal
  */
 public function pow(Decimal $b, $scale = null)
 {
     if ($b->isPositive()) {
         if ($this->isPositive()) {
             return $this;
         }
         // if ($this->isNegative())
         if ($b->isInfinite()) {
             throw new \DomainException("Negative infinite elevated to infinite is undefined.");
         }
         if ($b->isInteger()) {
             if (preg_match('/^[+\\-]?[0-9]*[02468](\\.0+)?$/', $b->value, $captures) === 1) {
                 // $b is an even number
                 return self::$pInf;
             } else {
                 // $b is an odd number
                 return $this;
                 // Negative Infinite
             }
         }
         throw new NotImplementedException("See issues #21, #22, #23 and #24 on Github.");
     } else {
         if ($b->isNegative()) {
             return DecimalConstants::Zero();
         } else {
             if ($b->isZero()) {
                 throw new \DomainException("Infinite elevated to zero is undefined.");
             }
         }
     }
 }