Skip to content

Conversation

@gerritholl
Copy link
Contributor

Clarified that round can take a negative value for ndigits.

Clarified that `round` can take a negative value for *ndigits*.
@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA. This is necessary for legal reasons before we can look at your contribution. Please follow these steps to help rectify the issue:

  1. If you don't have an account on b.p.o, please create one
  2. Make sure your GitHub username is listed in "Your Details" at b.p.o
  3. If you have not already done so, please sign the PSF contributor agreement. The "bugs.python.org username " requested by the form is the "Login name" field under "Your Details".
  4. If you just signed the CLA, please wait at least one US business day and then check "Your Details" on bugs.python.org to see if your account has been marked as having signed the CLA (the delay is due to a person having to manually check your signed CLA)
  5. Reply here saying you have completed the above steps

Thanks again to your contribution and we look forward to looking at it!

remove trailing whitespace in previous commit
@mdickinson mdickinson changed the title DOC: clarify documentation for round bpo-29677: DOC: clarify documentation for round Feb 28, 2017
nearest integer to its input. Delegates to ``number.__round__(ndigits)``.

For the built-in types supporting :func:`round`, values are rounded to the
closest multiple of 10 to the power minus *ndigits*; if two multiples are
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while we are modifying the doc, I dislike the start: "Return the floating point value number": number can be an integer. round(123, -2) doesn't use floating point numbers. Maybe rephrase to following text?

Return number rounded to (...). number can be an integer or a floating point number.

Or just remove "floating pointer number"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Haypo: agree:

Return number rounded to ndigits digits after the decimal point.

seems good to me.

About the negation, placement is good (too soon would have diluted the definition). About its wording, I'd prefer telling what it does instead of just stating it's possible, something like:

Negative ndigits permit rouding before the decimal point.

Copy link
Member

@vadmium vadmium Mar 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Victor, I agree the first sentence is too specific. But the number is not restricted to “int” and “float”. I expect it should work with anything implementing __round__. This is already hinted by the rest of the entry, as well as

https://docs.python.org/dev/reference/datamodel.html#object.__round__
https://docs.python.org/dev/library/numbers.html#numbers.Real
https://docs.python.org/dev/library/fractions.html#fractions.Fraction.__round__

Copy link
Member

@Mariatta Mariatta Mar 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we can accept this PR? If you would still like to see improvement with the first sentence, perhaps we can keep the issue open, so another person can work on it. Otherwise, @gerritholl's change in this PR seems good.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made a few changes trying to clarify the wording for round. I hope I didn't overstep any bounds. I researched other, similar functions and looked at the help(). In the first line I wanted to say 'Return the real number x', but float() didn't specify real number, even though they both don't work on Complex.

Anyway, this is my first pull, so I hope I did OK. :-)

@vstinner
Copy link
Member

vstinner commented Mar 2, 2017

CC @JulienPalard

@vstinner vstinner added the docs Documentation in the Doc dir label Mar 2, 2017
@vstinner vstinner merged commit 6003db7 into python:master Mar 27, 2017
Mariatta pushed a commit to Mariatta/cpython that referenced this pull request Mar 27, 2017
* DOC: clarify documentation for `round`

Clarified that `round` can take a negative value for *ndigits*.

* DOC: remove trailing whitespace in previous commit

remove trailing whitespace in previous commit

(cherry picked from commit 6003db7)
Mariatta pushed a commit to Mariatta/cpython that referenced this pull request Mar 27, 2017
* DOC: clarify documentation for `round`

Clarified that `round` can take a negative value for *ndigits*.

* DOC: remove trailing whitespace in previous commit

remove trailing whitespace in previous commit

(cherry picked from commit 6003db7)
Mariatta added a commit that referenced this pull request Mar 28, 2017
@Mariatta
Copy link
Member

Thanks @gerritholl for your first contribution to CPython 🎉
Thanks @Haypo for merging this. I cherry-picked this into 3.5 and 3.6, but getting conflict in 2.7, so I won't bother with that branch 🤷‍♀️

Mariatta added a commit that referenced this pull request Mar 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants