Пример #1
0
 /**
  * Compares this BigDecimal with the specified BigDecimal.
  *
  * Two BigDecimal objects that are equal in value but have a different scale (like 2.0 and 2.00)
  * are considered equal by this method. This method is provided in preference to individual
  * methods for each of the six boolean comparison operators (<, ==, >, >=, !=, <=).
  * The suggested idiom for performing these comparisons is: (x.compareTo(y) <op> 0),
  * where <op> is one of the six comparison operators.
  *
  * @param Number|float|int|string $that
  *
  * @return int - -1, 0, or 1 as this BigDecimal is numerically less than, equal to, or greater than val.
  *
  * @throws \DivisionByZeroError
  */
 public function compareTo($that)
 {
     $that = Number::of($that);
     if ($that instanceof BigInteger) {
         $that = $that->toBigDecimal();
     }
     if ($that instanceof self) {
         $this->scaleValues($this, $that, $a, $b);
         return Math::cmp($a, $b);
     }
     return -$that->compareTo($this);
 }