-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[Docs] Declare positive and negative convention in Round docs args #3183
Labels
documentation
Improvements or additions to documentation
good first issue
Good for newcomers
help wanted
Extra attention is needed
mojo-repo
Tag all issues with this label
Comments
DWSimmons
added
documentation
Improvements or additions to documentation
mojo-repo
Tag all issues with this label
labels
Jul 6, 2024
JoeLoser
added
help wanted
Extra attention is needed
good first issue
Good for newcomers
documentation
Improvements or additions to documentation
labels
Jul 17, 2024
— with
Linear
Clarifying this in the API docs would be great. Thanks for filing the issue. Feel free to submit a PR! |
This was referenced Aug 2, 2024
modularbot
added a commit
that referenced
this issue
Aug 7, 2024
…4681) [External] [Docs] Clarify the rounding in the builtin math module This addresses: [#3183. Previously, it was unclear how the math module rounded for negative numbers, this clears things up. ORIGINAL_AUTHOR=Pinak Paliwal <37413746 [email protected]> PUBLIC_PR_LINK=#3352 Co-authored-by: Pinak Paliwal <37413746 [email protected]> Closes #3352 MODULAR_ORIG_COMMIT_REV_ID: cdb50a3843db4f983c9688b2ab47f0b24f70fa1a
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
documentation
Improvements or additions to documentation
good first issue
Good for newcomers
help wanted
Extra attention is needed
mojo-repo
Tag all issues with this label
Where is the problem?
mojo/stdlib/src/builtin/math.mojo
Line 423 in 47ff10b
What can we do better?
Positive ndigits arg are rounded two digits to the right of the decimal (as in convention in other Python libraries) as the code suggests and performs...
round(1.2345, 2) # returns 1.23
Additionally,
Negative ndigits arg are counted from the decimal to the left
round(12345, -2) # returns 12000
I suggest adding a simple line that makes that explicit.
[Current] "ndigits: The number of digits to round to."
[ADD] Positive to the right of the decimal, negative to the left.
Anything else?
No response
The text was updated successfully, but these errors were encountered: