Fix issues with floating point precision and rounding #163
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit started off because I wanted to remove MPFR as a dependency. After an initially-incorrect attempt at doing so in #161, and a nice review by @PlasmaPower, I discovered two more problems. First, the test suite didn't have any tests verifying that MPFR actually fixed the problem it was introduced to fix (correctly rounding results like 0.1*1000 to 100 instead of 99). Second, MPFR gets 0.1*1000 right, but still makes rounding mistakes in other cases--I found this out by doing some fuzzing after my initial incorrect patch.
So now I've replaced MPFR with exact rational math in libgmp, and added regression tests for the rounding errors in string parsing. To do this, I had to do the parsing manually; I followed the same regex approach that the existing bs_size_new_from_str function uses.