{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/28878","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/28878/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/28878/comments","events_url":"https://api.github.com/repos/golang/go/issues/28878/events","html_url":"https://github.com/golang/go/issues/28878","id":382552023,"node_id":"MDU6SXNzdWUzODI1NTIwMjM=","number":28878,"title":"math/big: GCD support for negative and zero arguments","user":{"login":"TuomLarsen","id":2552859,"node_id":"MDQ6VXNlcjI1NTI4NTk=","avatar_url":"https://avatars1.githubusercontent.com/u/2552859?v=4","gravatar_id":"","url":"https://api.github.com/users/TuomLarsen","html_url":"https://github.com/TuomLarsen","followers_url":"https://api.github.com/users/TuomLarsen/followers","following_url":"https://api.github.com/users/TuomLarsen/following{/other_user}","gists_url":"https://api.github.com/users/TuomLarsen/gists{/gist_id}","starred_url":"https://api.github.com/users/TuomLarsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TuomLarsen/subscriptions","organizations_url":"https://api.github.com/users/TuomLarsen/orgs","repos_url":"https://api.github.com/users/TuomLarsen/repos","events_url":"https://api.github.com/users/TuomLarsen/events{/privacy}","received_events_url":"https://api.github.com/users/TuomLarsen/received_events","type":"User","site_admin":false},"labels":[{"id":373402289,"node_id":"MDU6TGFiZWwzNzM0MDIyODk=","url":"https://api.github.com/repos/golang/go/labels/NeedsInvestigation","name":"NeedsInvestigation","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/83","html_url":"https://github.com/golang/go/milestone/83","labels_url":"https://api.github.com/repos/golang/go/milestones/83/labels","id":3730798,"node_id":"MDk6TWlsZXN0b25lMzczMDc5OA==","number":83,"title":"Go1.13","description":null,"creator":{"login":"rsc","id":104030,"node_id":"MDQ6VXNlcjEwNDAzMA==","avatar_url":"https://avatars1.githubusercontent.com/u/104030?v=4","gravatar_id":"","url":"https://api.github.com/users/rsc","html_url":"https://github.com/rsc","followers_url":"https://api.github.com/users/rsc/followers","following_url":"https://api.github.com/users/rsc/following{/other_user}","gists_url":"https://api.github.com/users/rsc/gists{/gist_id}","starred_url":"https://api.github.com/users/rsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsc/subscriptions","organizations_url":"https://api.github.com/users/rsc/orgs","repos_url":"https://api.github.com/users/rsc/repos","events_url":"https://api.github.com/users/rsc/events{/privacy}","received_events_url":"https://api.github.com/users/rsc/received_events","type":"User","site_admin":false},"open_issues":162,"closed_issues":11,"state":"open","created_at":"2018-10-11T15:30:19Z","updated_at":"2018-11-20T22:18:55Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2018-11-20T08:33:14Z","updated_at":"2018-11-21T09:05:17Z","closed_at":null,"author_association":"NONE","body":"Please consider adding support for zero and negative arguments to `math/big` GCD.\r\n\r\nAs of version 1.11.1, to calculate GCD of two integers one has to write:\r\n\r\n    new(big.Int).GCD(nil, nil, new(big.Int).Abs(a), new(big.Int).Abs(b))\r\n\r\nIn other words, one needs two extra allocations (or copies) as the `nat` field of `big.Int` is private.\r\n\r\nIf on the other hand negative inputs were allowed the code would read:\r\n\r\n    new(big.Int).GCD(nil, nil, a, b)\r\n\r\nFor negative inputs the resulting GCD could be treated as GCD(|a|, |b|), the precise sign does not really matter as long as it is documented. (For example, \"GCD is non-negative\".)\r\n\r\nWhile I'm at it, it would be also nice to support zero arguments as it is [well defined](https://en.wikipedia.org/wiki/Greatest_common_divisor#Properties) (GCD(a, 0) = |a|, GCD(0, 0) = 0) and it would simplify the code because there would be no need to special-case zero inputs. [Currently](https://github.com/golang/go/blob/master/src/math/big/int.go#L490) it sets the result to zero."},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/440588344","html_url":"https://github.com/golang/go/issues/28878#issuecomment-440588344","issue_url":"https://api.github.com/repos/golang/go/issues/28878","id":440588344,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MDU4ODM0NA==","user":{"login":"TuomLarsen","id":2552859,"node_id":"MDQ6VXNlcjI1NTI4NTk=","avatar_url":"https://avatars1.githubusercontent.com/u/2552859?v=4","gravatar_id":"","url":"https://api.github.com/users/TuomLarsen","html_url":"https://github.com/TuomLarsen","followers_url":"https://api.github.com/users/TuomLarsen/followers","following_url":"https://api.github.com/users/TuomLarsen/following{/other_user}","gists_url":"https://api.github.com/users/TuomLarsen/gists{/gist_id}","starred_url":"https://api.github.com/users/TuomLarsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TuomLarsen/subscriptions","organizations_url":"https://api.github.com/users/TuomLarsen/orgs","repos_url":"https://api.github.com/users/TuomLarsen/repos","events_url":"https://api.github.com/users/TuomLarsen/events{/privacy}","received_events_url":"https://api.github.com/users/TuomLarsen/received_events","type":"User","site_admin":false},"created_at":"2018-11-21T09:05:17Z","updated_at":"2018-11-21T09:05:17Z","author_association":"NONE","body":"That would mutate the arguments, however. I don't think it is desirable to change `a` or `b` when asking for `new(big.Int)`.\r\n\r\nIf it worked as `GCD(|a|, |b|)` then I think the latter would make more sense. And you say for the case of zeros.\r\n\r\nNormalizing fractions, computing content of polynomials, simplify integer matrices, all these work beyond natural numbers."}}
{"actor":{"display_login":"TuomLarsen"}}