comp() 공개 메소드

$this > $b : returns 1 , $this < $b : returns -1 , $this == $b : returns 0
public comp ( Decimal $b, integer $scale = null ) : integer
$b Decimal
$scale integer
리턴 integer
예제 #1
0
 /**
  * Counts the number of significative digits of $val.
  * Assumes a consistent internal state (without zeros at the end or the start).
  *
  * @param  Decimal $val
  * @param  Decimal $abs $val->abs()
  * @return integer
  */
 private static function countSignificativeDigits(Decimal $val, Decimal $abs)
 {
     return strlen($val->value) - ($abs->comp(DecimalConstants::One()) === -1 ? 2 : max($val->scale, 1)) - ($val->isNegative() ? 1 : 0);
 }
예제 #2
0
파일: Money.php 프로젝트: coolms/money
 /**
  * Returns an integer less than, equal to, or greater than zero
  * if the value of this object is considered to be respectively
  * less than, equal to, or greater than the other
  *
  * @param Money $money
  * @return int
  */
 public function compare(Money $money)
 {
     $this->assertSameCurrency($money);
     return $this->amount->comp($money->amount, $this->getInnerPrecision());
 }