deveel-math
deveel-math copied to clipboard
Library is broken
Assert.AreEqual(16,
BigDecimal.Parse("9999,9999,9999,9999".Replace(",", ""))
.StripTrailingZeros().Precision);
It fails, with the actual value being 17 ... Yikes! Something to do with StripTrailingZeros ...
I've also seen issues with unnecessary rounding, when Parsing strings with a MathContext with a precision of 16, and where there's only been 16 digits. Probably negative numbers, cause I've seen negative numbers created using a big integer constructor, with a Precision of 17 when there's clearly only 16 digits, and that when you Abs() the value the Precision is 16.
I'm using <package id="dmath" version="1.5.66" targetFramework="net45" />
I feel like this package needs a lot more testing? I don't really have the time at the moment.
@sublimator thank you the report: this must be an issue that should be addressed.
As I specified, this library is a port of Harmony's Math package, that I adapted for .NET (for the code and the style), integrating it with some contributions for the big math functions. I used the same test suite as Harmony, that didn't include the test you've done.
It would be precious if you could help out fixing some things.
Thank you for the support.
I think this is a super useful project, but sadly there seems to be a few quirks.
If I can get some time I'll happily help out :)
Thank you for acknowledging the importance: it's actually a missing piece in .NET (even after 4.0 the decimals and astronomical numbers are missing). I've implemented it to support DeveelDB, so I've never dedicated much time to it, as I should, also because my math knowledge is limited to few courses at the university
I wish to thank you for any support you might give: I will try inspecting any case you will rise up
Maybe we can somehow use a Java bridge / J# runtime or something and generate a heap of tests, to match up the implementations ? And expose issues
It's a matter of licensing: I used Harmony's version of the Java Math package because it was licensed under MIT, while Java is not so lose on license. This allowed me to use the library also in loose (or commercial) projects.
How did you do the code conversion?
the old way: manually. :)
once it was ported and tested according to the test suite provided, I changed the design a bit, to make it more .NET fashion (.Parse, .TryParse, properties, etc.)