/** * 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); }
/** * 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()); }