{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/24515","repository_url":"https://api.github.com/repos/JuliaLang/julia","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/24515/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/24515/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/24515/events","html_url":"https://github.com/JuliaLang/julia/issues/24515","id":271927406,"number":24515,"title":"incorrect (Inf + Inf*im)^2.0 and other complex^float","user":{"login":"stevengj","id":2913679,"avatar_url":"https://avatars3.githubusercontent.com/u/2913679?v=4","gravatar_id":"","url":"https://api.github.com/users/stevengj","html_url":"https://github.com/stevengj","followers_url":"https://api.github.com/users/stevengj/followers","following_url":"https://api.github.com/users/stevengj/following{/other_user}","gists_url":"https://api.github.com/users/stevengj/gists{/gist_id}","starred_url":"https://api.github.com/users/stevengj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevengj/subscriptions","organizations_url":"https://api.github.com/users/stevengj/orgs","repos_url":"https://api.github.com/users/stevengj/repos","events_url":"https://api.github.com/users/stevengj/events{/privacy}","received_events_url":"https://api.github.com/users/stevengj/received_events","type":"User","site_admin":false},"labels":[{"id":172460713,"url":"https://api.github.com/repos/JuliaLang/julia/labels/complex","name":"complex","color":"bfe5bf","default":false},{"id":171885699,"url":"https://api.github.com/repos/JuliaLang/julia/labels/maths","name":"maths","color":"009800","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-11-07T17:59:32Z","updated_at":"2017-11-09T17:04:59Z","closed_at":null,"author_association":"OWNER","body":"In Julia 0.4–0.7, I get:\r\n```jl\r\njulia> (Inf + Inf*im)^2.0\r\n0.0 + Inf*im\r\n```\r\nwhich seems wrong (it assumes that the two `Inf` components are the \"same\").  The correct answer is given for `^2`:\r\n```jl\r\njulia> (Inf + Inf*im)^2\r\nNaN + Inf*im\r\n```\r\nThe error seems to be due to [this line](https://github.com/JuliaLang/julia/blob/00dafe28c05e35a3a6d6230a0effe2fcf628e8d4/base/complex.jl#L641), which dates back to #2891 by @jiahao.\r\n\r\nMy first inclination is to remove the entire `p==2` special case from this `^` method.  As I commented in #24497, that seems to be a performance optimization that is probably largely superseded, since most cases that need a fast `z^2` probably use (a) an integer exponent (that calls a different method) and/or (b) a literal integer exponent (for which `z^2` is inlined as `z*z` for `Complex64` and `Complex128`)."},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/343222106","html_url":"https://github.com/JuliaLang/julia/issues/24515#issuecomment-343222106","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/24515","id":343222106,"user":{"login":"stevengj","id":2913679,"avatar_url":"https://avatars3.githubusercontent.com/u/2913679?v=4","gravatar_id":"","url":"https://api.github.com/users/stevengj","html_url":"https://github.com/stevengj","followers_url":"https://api.github.com/users/stevengj/followers","following_url":"https://api.github.com/users/stevengj/following{/other_user}","gists_url":"https://api.github.com/users/stevengj/gists{/gist_id}","starred_url":"https://api.github.com/users/stevengj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevengj/subscriptions","organizations_url":"https://api.github.com/users/stevengj/orgs","repos_url":"https://api.github.com/users/stevengj/repos","events_url":"https://api.github.com/users/stevengj/events{/privacy}","received_events_url":"https://api.github.com/users/stevengj/received_events","type":"User","site_admin":false},"created_at":"2017-11-09T17:04:59Z","updated_at":"2017-11-09T17:04:59Z","author_association":"OWNER","body":"Wow, I found some even worse bugs:\r\n```jl\r\njulia> (0+0im)^-3.0\r\n0.0 + 0.0im\r\n```\r\nand\r\n```jl\r\njulia> @btime (1.0+0.0im)^1e300\r\nERROR: InexactError()\r\nStacktrace:\r\n [1] convert(::Type{Int64}, ::Float64) at ./float.jl:679\r\n [2] ^(::Complex{Float64}, ::Complex{Float64}) at ./complex.jl:593\r\n ...\r\n```"}}
{"actor":{"display_login":"stevengj"}}