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: (*Rat).SetString("1/0") should not be ok #8920

Closed
gopherbot opened this issue Oct 11, 2014 · 5 comments
Closed

math/big: (*Rat).SetString("1/0") should not be ok #8920

gopherbot opened this issue Oct 11, 2014 · 5 comments
Milestone

Comments

@gopherbot
Copy link

by casey.marshall:

Issue in 1.3 & tip.

Calling big.Rat.SetString with a rational string value that has a zero denominator will
produce an incorrect and unexpected result.

big.Rat.SetString simply assumes the denominator is 1 when it is actually 0.

big.Rat.SetString with a zero denominator should return nil, false.

http://play.golang.org/p/kTfKTZd8JI

-Casey
@minux
Copy link
Member

minux commented Oct 11, 2014

Comment 1:

I think we should detect this special case in (*Rat).SetString as if b is zero,
(*Rat).norm() will treat it as an integer with value a.

Labels changed: added release-go1.4maybe, repo-main.

Status changed to Accepted.

@gopherbot
Copy link
Author

Comment 3 by casey.marshall:

Proposed a fix: https://golang.org/cl/159760043/

@minux
Copy link
Member

minux commented Oct 12, 2014

Comment 4:

Add "Fixes issue #8920" to your CL description, and run "hg mail 159760043", otherwise we
can't see it.

@gopherbot
Copy link
Author

Comment 5:

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

@griesemer
Copy link
Contributor

Comment 6:

Fixed with r=0ca77a6b76c1a990f7c01ba84381bc95ae8cbc81.

Status changed to Fixed.

@rsc rsc added this to the Go1.4 milestone Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
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

4 participants