-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More efficient rounding #42
Open
arash-binary
wants to merge
28
commits into
deriv-com:master
Choose a base branch
from
arash-binary:underlyings/refactor_pip_size
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
More efficient rounding #42
arash-binary
wants to merge
28
commits into
deriv-com:master
from
arash-binary:underlyings/refactor_pip_size
Conversation
This file contains 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
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
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
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