/** * 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); }
/** * toInteger. * * @param RoundingMode $roundingMode * * @return IntVal */ public function toInteger(RoundingMode $roundingMode = null) { return IntVal::fromReal($this, $roundingMode); }