Open
Conversation
Math::BigFloat is one of the reasons pip sizing is so slow Replace it with Math::Round
junbon-deriv
approved these changes
Oct 27, 2021
Contributor
|
we probably need a PR in |
Numbers like 0.5 has floating point issues for very big precisions. For instance you get 0.499999999999999944 for 0.5 with 18 decimal point precision. By turning this number into string as the input of sprintf, we avoid this issue
In crypto repo we use `roundcommon` function for precisions up to 18 digits. This is while double precision data types can hold up to around 15 digits numbers. So we use the BigFloat for big numbers and keep nearest for smaller numbers (faster!)
Count the digits and based on that choose which technique to use
…underlyings/refactor_pip_size
junbon-deriv
approved these changes
Nov 17, 2021
nearest function does not do any magic. It's rather easy to understand what's happening in the code. The tricky part if when to swtich to Math::BigFloat
Since in here we only want to do rounding and no mathematical operation is happening, we will do our rounding based on string values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Math::BigFloat is one of the reasons pip sizing is so slow
Replace it with Math::Round