-
-
Notifications
You must be signed in to change notification settings - Fork 7
[add] Implement variable padding in number rounding #55
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
Conversation
|
Hi @initramfs , thank you, this seems like a useful addition. I think that in |
|
I had already implement sigfig-based padding as seen here (but scrapped it for the initial PR): Since this requires clarification of the semantics of I've added another commit that defines |
|
Looks good now! Can you add a few tests to And maybe we should mention that |
|
Added tests and docs. I amended the existing |
3a9019b to
3fd9c6e
Compare
Explicitly specify that the `pad` parameter in rounding has no effect when `mode` is set to "uncertainty".
3fd9c6e to
e2f06a2
Compare
|
Thank you! 🎉 |
This PR adds the ability to specify an integer value for the
padparameter within therounddictionary in order to "only" pad to the specific number of decimal digits.To demonstrate with an example:
would yield:
The main purpose of this is essentially to specify a minimum bound on the number of decimal digits, useful in cases like always displaying a decimal point (for integers), or to display to a fixed number of fractional digits on average but allowing more precise figures to exceed the digit count (by setting
precisionhigh andpadto the expected number of decimal digits on average).This change remains backwards-compatible with the existing specification of
pad: trueorpad: falseas it merely adds an integer overload ontop of the existing behaviour.