-
Notifications
You must be signed in to change notification settings - Fork 78
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
Fix: bigNumberToString fn also return <0.001 #2215
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left feedback on how I think this should be done
app/src/util/tools/formatting.ts
Outdated
if (Number(number) < 0.001 && Number(number) > 0 && decimals > 2) { | ||
return '<0.001' | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Frankaus This works but I don't think its the best approach. So we wanna make it so that according to number of decimal places (precision) we define it checks for that amount of less then decimal places.
For example :
If we have one decimal place it will evaluate to <0.1
if we have 2 decimals it will evaluate to <0.01
if we have 3 decimals it will evaluate to <0.001
if we have 4 decimal it will evaluate to <0.0001
etc....
And we should make it in one place and to do this programatically not hardcoding it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely better approach yes. I thought of a for loop and it works on my machine. That should do the job, hope you like it. Thank you!
app/src/util/tools/formatting.ts
Outdated
if (Number(number) > 0) { | ||
for (let i = 1; i < 10; i++) { | ||
if (Number(number) < Number('0.' + '0'.repeat(i) + '1') && decimals === i + 1) { | ||
return '<0.' + '0'.repeat(i) + '1' | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Frankaus Why are we making this loop which loops to 10? I think because we have decimals we can just determine which evaluation we need to do and use the value for evaluation to be based on number of decimals....
@Frankaus Im getting this error. Please test pr-s first its like this on main page or did I do something wrong? |
@hexyls Hey men would be good if you have time to take a look I added tests also and it should act as expected...But haven't dwelled that much how it looks on components themselves or if it has some issues. But should work in theory... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
closes #2214
Testing
After merging #2169 you can test this feature in the Set Outcome stage of the market bond component in the Potential Fee entry row having
<0.001
while other entries in market buy still show<0.01