Beispiel #1
0
 /**
  * @dataProvider minMaxProvider
  */
 public function testMax(DecimalValue $min, DecimalValue $max)
 {
     $math = new DecimalMath();
     $actual = $math->max($min, $max);
     $this->assertEquals($max->getValue(), $actual->getValue());
     $actual = $math->max($max, $min);
     $this->assertEquals($max->getValue(), $actual->getValue());
 }
Beispiel #2
0
 /**
  * Returns a DecimalValue representing the symmetrical offset to be applied
  * to the raw amount for a rough representation of the uncertainty interval,
  * as in "amount +/- offset".
  *
  * The offset is calculated as max( amount - lowerBound, upperBound - amount ).
  *
  * @since 0.1
  *
  * @return DecimalValue
  */
 public function getUncertaintyMargin()
 {
     $math = new DecimalMath();
     $lowerMargin = $math->sum($this->getAmount(), $this->getLowerBound()->computeComplement());
     $upperMargin = $math->sum($this->getUpperBound(), $this->getAmount()->computeComplement());
     $margin = $math->max($lowerMargin, $upperMargin);
     return $margin;
 }