public static function fromReal(Real $real, RoundingMode $roundingMode = null, $force = true) { if (!$force && $real->lessThan(new Number(1))) { throw new ValueNotConvertibleException($real); } return parent::fromReal($real, $roundingMode, $force); }
/** * fromReal. * * @param Real $real * @param RoundingMode $roundingMode * @param bool $force * * @return static */ public static function fromReal(Real $real, RoundingMode $roundingMode = null, $force = true) { if (!$force && $real->lessThan(new Number(0))) { throw new ValueNotConvertibleException($real); } if (null === $roundingMode) { $roundingMode = RoundingMode::HALF_UP(); } $naturalValue = abs(Integer::fromReal($real, $roundingMode)->value()); return new static($naturalValue); }