/** * Returns a Complex given polar coordinates * * @param Real $modulus * @param Real $argument * @return Complex */ public static function fromPolar(Real $modulus, Real $argument) { $realValue = $modulus->toNative() * \cos($argument->toNative()); $imValue = $modulus->toNative() * \sin($argument->toNative()); $real = new Real($realValue); $im = new Real($imValue); $complex = new static($real, $im); return $complex; }
/** * Multiply the Money amount for a given number and returns a new Money object. * Use 0 < Real $multipler < 1 for division. * * @param Real $multiplier * @param mixed $rounding_mode Rounding mode of the operation. Defaults to RoundingMode::HALF_UP. * @return Money */ public function multiply(Real $multiplier, RoundingMode $rounding_mode = null) { if (null === $rounding_mode) { $rounding_mode = RoundingMode::HALF_UP(); } $amount = $this->getAmount()->toNative() * $multiplier->toNative(); $roundedAmount = new Integer(round($amount, 0, $rounding_mode->toNative())); $result = new self($roundedAmount, $this->getCurrency()); return $result; }
/** * Returns the value of the integer number * * @return int */ public function toNative() { $value = parent::toNative(); return \intval($value); }
public function testToNative() { $real = new Real(3.4); $this->assertEquals(3.4, $real->toNative()); }