/**
  * This method tests the "compare" method.
  *
  * @dataProvider data_compare
  */
 public function test_compare(array $provided, array $expected)
 {
     $p0 = IInt32\Module::compare(IInt32\Type::box($provided[0]), IInt32\Type::box($provided[1]));
     $e0 = $expected[0];
     $this->assertInstanceOf('\\Saber\\Data\\ITrit\\Type', $p0);
     $this->assertSame($e0, $p0->unbox());
 }
Exemple #2
0
 /**
  * This method returns the numerically lowest value.
  *
  * @access public
  * @static
  * @param IInt32\Type $x                                    the left operand
  * @param IInt32\Type $y                                    the right operand
  * @return IInt32\Type                                      the minimum value
  */
 public static function min(IInt32\Type $x, IInt32\Type $y) : IInt32\Type
 {
     return IInt32\Module::compare($x, $y)->unbox() <= 0 ? $x : $y;
 }
Exemple #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()));
 }