Beispiel #1
0
 /**
  * Compares the Ratio with another at the specified scale.
  *
  * @param Ratio $other
  * @param int   $scale
  *
  * @return int An integer less than, equal to or greater than 0 when this instance is respectively less than,
  *             equal to or greater than the $other instance.
  */
 public function compare(Ratio $other, int $scale = null) : int
 {
     if ($this === $other) {
         return 0;
     }
     return $this->toDecimal()->compare($other->toDecimal(), $scale);
 }
Beispiel #2
0
 /**
  * Converts this decimal to a ratio.
  *
  * For example, given the decimal 1.5 this will return the ratio 2:1.
  *
  * @return Ratio
  */
 public function toRatio() : Ratio
 {
     $ratio = new Ratio($this, new Decimal('1'));
     return $ratio->simplify();
 }