public function testString() { // Arrange $value = '0.0000000000000009'; // Act $result = Utils::convertExponentialToString($value); // Assert $this->assertEquals('0.0000000000000009', $result); }
/** * A helper method to set the value on this class. * * @param int|string|BigNumber $value The value to assign. * @return BigNumber */ private function internalSetValue($value) { if (is_float($value)) { $valueToSet = Utils::convertExponentialToString($value); } else { $valueToSet = (string) $value; } if (!is_numeric($valueToSet)) { throw new InvalidArgumentException('Invalid number provided: ' . $valueToSet); } // We use a slick trick to make sure the scale is respected. $this->value = bcadd(0, $valueToSet, $this->getScale()); return $this; }