moneyphp / money

PHP implementation of Fowler's Money pattern.
http://moneyphp.org
MIT License
4.56k stars 439 forks source link

SwapExchange does not work with small floating point numbers #743

Closed martiis closed 1 year ago

martiis commented 1 year ago

If SwapExchange would return a rate like 0.0000550000 PHP will display as 5.5E-5 thus simply casting to string will result to "5.5E-5". Then Converter passes ratio to the Number class which will throw invalid fractional part exception.

Although this issue has been handled in ExchangerExchange by using sprintf :)

frederikbosch commented 1 year ago

If you can make a PR with the sprintf solution, including a test, would be great.