示例#1
0
 /**
  * This method tests the "multiply" method.
  *
  * @dataProvider data_multiply
  */
 public function test_multiply(array $provided, array $expected)
 {
     $p0 = IInt32\Module::multiply(IInt32\Type::box($provided[0]), IInt32\Type::box($provided[1]));
     $e0 = $expected[0];
     $this->assertInstanceOf('\\Saber\\Data\\IInt32\\Type', $p0);
     $this->assertEquals($e0, $p0->unbox());
 }
示例#2
0
 /**
  * This method computes the nth factorial number.
  *
  * @access public
  * @static
  * @param IInt32\Type $n                                    the operand
  * @return IInt32\Type                                      the result
  */
 public static function factorial(IInt32\Type $n) : IInt32\Type
 {
     return IInt32\Module::eq($n, IInt32\Type::zero())->unbox() ? IInt32\Type::one() : IInt32\Module::multiply($n, IInt32\Module::factorial(IInt32\Module::decrement($n)));
 }
示例#3
0
 /**
  * This method compares the operands for order.
  *
  * @access public
  * @static
  * @param IRatio\Type $x                                    the left operand
  * @param IRatio\Type $y                                    the right operand
  * @return ITrit\Type                                       the order as to whether the left
  *                                                          operand is less than, equals to,
  *                                                          or greater than the right operand
  */
 public static function compare(IRatio\Type $x, IRatio\Type $y) : ITrit\Type
 {
     return IInt32\Module::compare(IInt32\Module::multiply($x->numerator(), $y->denominator()), IInt32\Module::multiply($y->numerator(), $x->denominator()));
 }