Esempio n. 1
0
 /**
  * Divides $this by $divisor and returns a new value object.
  * Uses the default rounding method (ROUND_HALF_EVEN) which is preferred for financial calculations.
  * @param Money|int|float|string $divisor
  * @return Money|string
  */
 public function divide($divisor)
 {
     if ($divisor instanceof Money) {
         return $this->mathProvider->divide($this->getValue(), $divisor->getValue(), MathProvider::ROUND_MODE_NONE);
     } else {
         return new static($this->mathProvider->divide($this->getValue(), (string) $divisor), $this->mathProvider);
     }
 }
Esempio n. 2
0
 /**
  * @see Object_Class_Data::getVersionPreview
  * @param float $data
  * @return float
  */
 public function getVersionPreview($data)
 {
     if ($data instanceof \Object_Data_QuantityValue) {
         return $data->getValue() . " " . $data->getUnit()->getAbbreviation();
     }
     return "";
 }
Esempio n. 3
0
 /**
  * @see Object_Class_Data::getVersionPreview
  * @param float $data
  * @param null|Model\Object\AbstractObject $object
  * @param mixed $params
  * @return float
  */
 public function getVersionPreview($data, $object = null, $params = [])
 {
     if ($data instanceof \Pimcore\Model\Object\Data\QuantityValue) {
         $unit = "";
         if ($data->getUnitId()) {
             $unitDefinition = Model\Object\QuantityValue\Unit::getById($data->getUnitId());
             if ($unitDefinition) {
                 $unit = " " . $unitDefinition->getAbbreviation();
             }
         }
         return $data->getValue() . $unit;
     }
     return "";
 }
Esempio n. 4
0
 /**
  * Ceil a float
  * 
  * @param \Scalar\Float $float eg 13.22222
  * @return float eg 14.0
  */
 public function direct(float $float)
 {
     return ceil($float->getValue());
 }
Esempio n. 5
0
 /**
  * Marshall a QTI float datatype into its PCI JSON Representation.
  *
  * @param \qtism\common\datatypes\Float $float
  * @return array
  */
 protected function marshallFloat(float $float)
 {
     return array('base' => array('float' => $float->getValue()));
 }
 /**
  * Get the Radius of Curvature along the Prime Vertical at a specified latitude
  * for this Reference Ellipsoid object
  *
  * The formula used here is from http://www.epsg.org/guides/docs/G7-2.pdf
  *
  * @param     integer|float    $latitude    Angle of Latitude for the Radius of Curvature,
  *                                              positive when to the north of the equator, negative when to the south
  * @param     string           $degrad      Indicating whether the Angle of Latitude is being specified
  *                                              in degrees or radians
  * @param     string           $uom         Unit of Measure for the returned value
  * @return    float            The Radius of Curvature along the Prime Vertical at the specified latitude
  *                                 for this ellipsoid
  * @throws    Exception
  */
 public function getRadiusOfCurvaturePrimeVertical($latitude = null, $degrad = Angle::DEGREES, $uom = Distance::METRES)
 {
     $latitude = LatLong::validateLatitude($latitude, $degrad);
     if ($this->dirty) {
         $this->calculateDerivedParameters();
     }
     $radius = $this->semiMajorAxis->getValue() / pow(1 - $this->firstEccentricitySquared * self::sinSquared($latitude), 0.5);
     return Distance::convertFromMeters($radius, $uom);
 }
Esempio n. 7
0
 /**
  * Testing addition of two Double values.
  *
  * @since 1.0
  */
 public function testAddDoubles()
 {
     $this->dbl1 = new Double(1.25);
     $this->dbl2 = new Double(3.5);
     $this->assertEquals(4.75, $this->dbl1->getValue() + $this->dbl2->getValue(), 'testing addition of two Double values');
 }