예제 #1
0
 /**
  * @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);
 }
예제 #2
0
 /**
  * @dataProvider significantDigitsProvider
  */
 public function testSignificantDigits(Number $number, $expectedSignificantDigits)
 {
     $this->assertEquals($expectedSignificantDigits, $number->getSignificantDigits());
 }