Closed sh41 closed 3 years ago
@sh41 thank you for bringing this to the table. There should at the very least be range validation for a clearer, more controlled error state. I don't think there is an intuitive meaning of a negative number here.
This has been fixed and released as part of v1.4.0
First up, thanks for this extension. It has made my life so much easier since I moved all of my code from bcmath to this.
I recently ran into a bug and am posting here to hopefully save someone time in the future.
Steps to reproduce:
Result:
You could also use this script to reproduce if you already have a working installation of php with ext-decimal
which outputs:
I understand that passing a negative number to
Decimal::toFixed
is incorrect, but an uncatchable Fatal error with a message about memory allocation made tracking down the bug quite difficult. My suggestion, if anyone has the time or inclination to look at this, is to have a clearer error message here that the argument of -1 is invalid.Thanks again