Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Leading decimal not supported in fromString #76

Open
mareeo opened this issue Mar 14, 2022 · 0 comments
Open

Leading decimal not supported in fromString #76

mareeo opened this issue Mar 14, 2022 · 0 comments

Comments

@mareeo
Copy link

mareeo commented Mar 14, 2022

When creating from a string value leading decimals cause a NaNInputError.

// Works
\Litipk\BigNumbers\Decimal::fromString('0.110');

// PHP Fatal error:  Uncaught Litipk\BigNumbers\Errors\NaNInputError: strValue must be a number
\Litipk\BigNumbers\Decimal::fromString('.110');

A simple fix would be adding the following to fromString()

if (substr($strValue, 0, 1) === '.') {
    $strValue = '0' . $strValue;
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant