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: Float.Copy doc string can be misleading #66358

Open
griesemer opened this issue Mar 17, 2024 · 1 comment · May be fixed by #66539
Open

math/big: Float.Copy doc string can be misleading #66358

griesemer opened this issue Mar 17, 2024 · 1 comment · May be fixed by #66539
Assignees
Milestone

Comments

@griesemer
Copy link
Contributor

Reminder issue to review this documentation in math/big:

// Copy sets z to x, with the same precision, rounding mode, and
// accuracy as x, and returns z. x is not changed even if z and
// x are the same.
func (z *Float) Copy(x *Float) *Float

The 2nd sentence is confusing.

@griesemer griesemer added this to the Backlog milestone Mar 17, 2024
@griesemer griesemer self-assigned this Mar 17, 2024
@robpike
Copy link
Contributor

robpike commented Mar 17, 2024

I was bitten by this because if x and z are the same, as in y := x.Copy(x), which seems prima facie to be how one might use this, it doesn't do what it looks like: x and y are now the same memory, despite y looking like it's a copy.

Perhaps some examples would help (there are none). Also the last sentence might instead be:

If x and z are the same Float, x will not be changed but the return value will also not be a copy of x.

@pikomonde pikomonde linked a pull request Mar 26, 2024 that will close this issue
@griesemer griesemer modified the milestones: Backlog, Go1.23 Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants