Skip to content
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

math/big: Typo in the documentation of Int.DivMod #13875

Closed
TomCoates8161 opened this issue Jan 8, 2016 · 4 comments
Closed

math/big: Typo in the documentation of Int.DivMod #13875

TomCoates8161 opened this issue Jan 8, 2016 · 4 comments

Comments

@TomCoates8161
Copy link

The documentation for DivMod, in the big library, suggests that z.DivMod(x,y,w) sets z to the quotient q and w to the modulus m, where q and m satisfy

m = x - y*q with 0 <= m < |q|

I believe that this should read

m = x - y*q with 0 <= m < |y|

so that it agrees with the reference mentioned in the documentation for DivMod: Raymond T. Boute, “The Euclidean definition of the functions div and mod”. ACM Transactions on Programming Languages and Systems (TOPLAS), 14(2):127-144, New York, NY, USA, 4/1992. ACM press.

@TomCoates8161 TomCoates8161 changed the title mistake in the definition of DivMod math/big: mistake in the definition of DivMod Jan 8, 2016
@ianlancetaylor
Copy link
Contributor

I can't tell: is this a problem with the docs, or a problem with the code?

@TomCoates8161
Copy link
Author

Code looks OK to me.

@rsc
Copy link
Contributor

rsc commented Jan 8, 2016

Yes, if the operation is q=x/y then clearly the remainder (sorry, modulus) must be < y, not < q. Thanks.

@griesemer griesemer changed the title math/big: mistake in the definition of DivMod math/big: Typo in the documentation of Int.DivMod Jan 8, 2016
@gopherbot
Copy link

CL https://golang.org/cl/18441 mentions this issue.

@golang golang locked and limited conversation to collaborators Jan 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants