AdamWhiteHat / BigDecimal

An arbitrary-precision decimal (base 10) floating-point number class.
MIT License
47 stars 15 forks source link

Invalid Parse result of negative number in scientific notation #15

Closed Degot closed 10 months ago

Degot commented 10 months ago

Bug: input = input.Replace(numberFormatProvider.NegativeSign, String.Empty);

if input starts with NegativeSign, it will replace ALL NegativeSigns in the string.

To Fix: input = input.Substring(1); To Test: new BigDecimal("-123.123E-20");

AdamWhiteHat commented 10 months ago

Thanks for bringing this to my attention. Good catch. I decided upon using TrimStart instead. This should be fixed now. I added some tests to the test project to using your example string to parse to ensure correctness and prevent against behavior regression.

Pull the latest changes from the main branch and test it out, if you like. If you are satisfied with the fix, you can close this issue. Or do nothing; If I don't hear anything from after about a week, I will close the ticket on your behalf.

Degot commented 10 months ago

I've tested fix. It works as expected. Thank you.