示例#1
0
 /** @test */
 public function should_subtract_two_numbers()
 {
     $command = new SubtractCommand(new AnyNumber(15.8889), new AnyNumber(2.1237), new PositiveNumber(4));
     $total = $command->run();
     $this->assertInstanceOf('PhilipBrown\\Math\\Number', $total);
     $this->assertEquals(13.7652, $total->value());
 }
示例#2
0
文件: Math.php 项目: philipbrown/math
 /**
  * Subtract two numbers
  *
  * @param mixed $left
  * @param mixed $right
  * @param mixed $scale
  * @return Number
  */
 public static function subtract($left, $right, $scale = 0)
 {
     $left = new AnyNumber($left);
     $right = new AnyNumber($right);
     $scale = new PositiveNumber($scale);
     $command = new SubtractCommand($left, $right, $scale);
     return $command->run();
 }