/** * @param \ScientificNotation\Number $number * @param string $input */ private function populateNumberFromFloat(\ScientificNotation\Number $number, $input) { if ($input == 0) { $number->setCoefficient(0.0); $number->setExponent(0); return; } $exponent = (int) floor(log10($input)); $coefficient = (double) pow(10, -$exponent) * $input; $number->setCoefficient($coefficient); $number->setExponent($exponent); }
/** * @dataProvider significantDigitsProvider */ public function testSignificantDigits(Number $number, $expectedSignificantDigits) { $this->assertEquals($expectedSignificantDigits, $number->getSignificantDigits()); }