Closed SGStino closed 1 year ago
This should be fixed now. Thank you for bringing it to my attention.
BigRational.Negate was not handling the case where the WholePart was zero. BigRational.Compare and the explicit conversion methods from BigRational to double and to decimal also needed to consider this case and so their logic was also updated.
A new NuGet version reflecting these changes have been uploaded and is now available: 2023.179.1529
You can close this issue if you are satisfied, otherwise I will probably close this issue in about week or so if I don't hear anything else from you.
Using the new nuget in my test project my test cases also pass. Although they aren't as exhaustive as yours. Thanks.
Description numbers like -0.0001 have a whole part of 0 and a fractional part of 1 /10000, but whole and fractional are positive (sign = 1). So nothing stores the sign of the complete number.
Error/Exception Message If you try the following in RoslynPad:
you'll get:
Expected Behavior
(-value).Sign
should be-1
andvalue.Sign
should be1
Andvalue.Whole.Sign
can remain0
, but thenvalue.Fraction.Sign
should become-1
in the negative case. Actual Behavior Both signs are 0 due to the sign being taken entirely from the whole part.Notes Explicitly creating a negative fraction results in
Sign
=0
Because the sign of the Fractional isn't even preserved when negating the entire number.