示例#1
0
 /**
  * This method tests the "isNegative" method.
  *
  * @dataProvider data_isNegative
  */
 public function test_isNegative(array $provided, array $expected)
 {
     $p0 = IDouble\Module::isNegative(IDouble\Type::box($provided[0]));
     $e0 = $expected[0];
     $this->assertInstanceOf('\\Saber\\Data\\IBool\\Type', $p0);
     $this->assertSame($e0, $p0->unbox());
 }
示例#2
0
 /**
  * This method returns the value as an IInteger. Note: Using this method may result in
  * lost of precision.
  *
  * @access public
  * @static
  * @param IRatio\Type $x                                    the object to be converted
  * @return IInteger\Type                                    the value as an IInteger
  */
 public static function toInteger(IRatio\Type $x) : IInteger\Type
 {
     return IDouble\Module::toInteger(IRatio\Module::toDouble($x));
 }
示例#3
0
 /**
  * This method returns the numerically lowest value.
  *
  * @access public
  * @static
  * @param IDouble\Type $x                                   the left operand
  * @param IDouble\Type $y                                   the right operand
  * @return IDouble\Type                                     the minimum value
  */
 public static function min(IDouble\Type $x, IDouble\Type $y) : IDouble\Type
 {
     return IDouble\Module::compare($x, $y)->unbox() <= 0 ? $x : $y;
 }
示例#4
0
 /**
  * This method returns the sum of all items in the list.
  *
  * @access public
  * @static
  * @param ISeq\Type $xs                                     the sequence to be processed
  * @return IDouble\Type                                     the result
  */
 public static function sum(ISeq\Type $xs) : IDouble\Type
 {
     return $xs->foldLeft(function (IDouble\Type $c, INumber\Type $x) {
         return IDouble\Module::add($c, $x->toDouble());
     }, IDouble\Type::zero());
 }