/** * @test */ public function check_idempotent_float_number_conversion() { $f0 = new FN(12.89); $this->assertTrue($f0->equals(12.89)); $f = new FN($f0->__toString()); $this->assertTrue($f->equals(12.89)); foreach (range(1, 99) as $i) { $f = new FN($f->__toString()); $this->assertTrue($f->equals(12.89)); } $this->assertTrue($f->equals($f0)); }
/** * Check if this number is less than the given value * * @param N $other * * @return mixed */ protected function _lt(N $other) { if (!$other instanceof FloatNumber) { $other = new FloatNumber($other->__toString()); } $scales = self::getScales($this, $other); $l = $this->copy($scales[1]); $r = $other->copy($scales[1]); $ls = preg_replace("#[^0-9\\-]#", '', $l->__toString()); $rs = preg_replace("#[^0-9\\-]#", '', $r->__toString()); return (new IntegerNumber($ls))->lt(new IntegerNumber($rs)); }