/**
  * Builds a new euclidian division result from given numbers.
  *
  * @param IInteger $numerator
  * @param IInteger $denominator
  */
 public function __construct(IInteger $numerator, IInteger $denominator)
 {
     $this->_numerator = $numerator;
     $this->_denominator = $denominator;
     $this->_quotient = $numerator->divide($denominator)->round(Integer::fromPrimitive(0));
     $this->_remainder = $numerator->substract($denominator->multiply($this->_quotient));
 }
Beispiel #2
0
 /**
  * {@inheritDoc}
  * @see \PhpObject\Core\INumber::round($precision)
  */
 public function round(IInteger $precision) : IFloat
 {
     return new Integer(round($this->getPrimitive(), $precision->getPrimitive(), PHP_ROUND_HALF_DOWN));
 }
Beispiel #3
0
 /**
  * {@inheritDoc}
  * @see \PhpObject\Core\IString::substring($start, $length)
  */
 public function substring(IInteger $start, IInteger $length) : IString
 {
     return new String(substr($this->getPrimitive(), $start->getPrimitive(), $length->getPrimitive()));
 }