示例#1
0
 /**
  * Process flooring command
  *
  * @param Number\Number         $number
  * @param Number\PositiveNumber $scale
  *
  * @return Number\Number
  */
 public static function process(Number\Number $number, Number\PositiveNumber $scale)
 {
     $multiplier = Power::process(Number\Number::create(10), $scale, Number\PositiveNumber::create(0));
     $number = Multiplication::process($number, $multiplier, Number\PositiveNumber::create(0));
     $operand = Comparison::process($number, Number\Number::create(0), Number\PositiveNumber::create($scale))->getValue() == 1 ? Addition::process($number, Number\PositiveNumber::create(0), Number\PositiveNumber::create(0)) : Subtraction::process($number, Number\PositiveNumber::create(1), Number\PositiveNumber::create(0));
     return Division::process($operand, $multiplier, $scale);
 }
示例#2
0
 /**
  * Process comparison command
  *
  * @param Number\Number         $left
  * @param Number\Number         $right
  * @param Number\PositiveNumber $scale
  *
  * @return Number\Number
  */
 public static function process(Number\Number $left, Number\Number $right, Number\PositiveNumber $scale)
 {
     $command = self::COMMAND;
     return Number\Number::create($command($left->getValue(), $right->getValue(), $scale->getValue()));
 }
示例#3
0
 /**
  * Gets number smaller than scale fits
  *
  * @param Number\PositiveNumber $scale
  *
  * @return Number\Number
  */
 protected static function getSmallNumber(Number\PositiveNumber $scale)
 {
     return Division::process(Number\Number::create(1), Power::process(Number\Number::create(10), $scale, Number\PositiveNumber::create(0)), Number\PositiveNumber::create($scale));
 }