Ejemplo n.º 1
0
 /**
  * Returns the maximum of the two values
  *
  * @param DecimalValue $a
  * @param DecimalValue $b
  *
  * @return DecimalValue
  */
 public function max(DecimalValue $a, DecimalValue $b)
 {
     if ($this->useBC) {
         $scale = max(strlen($a->getFractionalPart()), strlen($b->getFractionalPart()));
         $comp = bccomp($a->getValue(), $b->getValue(), $scale);
         $max = $comp > 0 ? $a : $b;
     } else {
         $max = max($a->getValueFloat(), $b->getValueFloat());
         $max = $this->makeDecimalValue($max);
     }
     return $max;
 }
Ejemplo n.º 2
0
 /**
  * @dataProvider getValueFloatProvider
  */
 public function testGetValueFloat(DecimalValue $value, $expected)
 {
     $actual = $value->getValueFloat();
     $this->assertSame($expected, $actual);
 }