Beispiel #1
0
 /**
  * Check if the given value is equals to this number
  *
  * @param N $other
  *
  * @return bool
  */
 protected function _equals(N $other)
 {
     if ($other instanceof FloatNumber) {
         return $this->__toString() == $other->__toString();
     } else {
         return $this->__toString() == (new FloatNumber($other->__toString()))->__toString();
     }
 }
Beispiel #2
0
 /**
  * @test
  * @dataProvider numbers
  */
 public function to_string_numbers(N $i, $expected)
 {
     $this->assertSame($expected, $i->__toString());
 }
Beispiel #3
0
 /**
  * Sub two Numbers
  * $l - $r
  *
  * @param VONumber $l
  * @param VONumber $r
  *
  * @return VONumber
  */
 public function sub(VONumber $l, VONumber $r)
 {
     if ($l instanceof IntegerNumber && $r instanceof IntegerNumber) {
         return new IntegerNumber(bcsub($l->__toString(), $r->__toString()));
     } else {
         $scale = FloatNumber::getScales($l, $r);
         $res = new FloatNumber(bcsub($l->__toString(), $r->__toString(), $scale[1]), $scale[0]);
         return $res;
     }
 }