{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/5290","repository_url":"https://api.github.com/repos/JuliaLang/julia","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/5290/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/5290/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/5290/events","html_url":"https://github.com/JuliaLang/julia/issues/5290","id":24998043,"number":5290,"title":"behavior of cmp() on NaNs?","user":{"login":"jiahao","id":1732,"avatar_url":"https://avatars.githubusercontent.com/u/1732?v=3","gravatar_id":"","url":"https://api.github.com/users/jiahao","html_url":"https://github.com/jiahao","followers_url":"https://api.github.com/users/jiahao/followers","following_url":"https://api.github.com/users/jiahao/following{/other_user}","gists_url":"https://api.github.com/users/jiahao/gists{/gist_id}","starred_url":"https://api.github.com/users/jiahao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jiahao/subscriptions","organizations_url":"https://api.github.com/users/jiahao/orgs","repos_url":"https://api.github.com/users/jiahao/repos","events_url":"https://api.github.com/users/jiahao/events{/privacy}","received_events_url":"https://api.github.com/users/jiahao/received_events","type":"User","site_admin":false},"labels":[{"id":371587497,"url":"https://api.github.com/repos/JuliaLang/julia/labels/design","name":"design","color":"e99695","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":{"url":"https://api.github.com/repos/JuliaLang/julia/milestones/20","html_url":"https://github.com/JuliaLang/julia/milestones/0.6.0","labels_url":"https://api.github.com/repos/JuliaLang/julia/milestones/20/labels","id":1298021,"number":20,"title":"0.6.0","description":"","creator":{"login":"JeffBezanson","id":744556,"avatar_url":"https://avatars.githubusercontent.com/u/744556?v=3","gravatar_id":"","url":"https://api.github.com/users/JeffBezanson","html_url":"https://github.com/JeffBezanson","followers_url":"https://api.github.com/users/JeffBezanson/followers","following_url":"https://api.github.com/users/JeffBezanson/following{/other_user}","gists_url":"https://api.github.com/users/JeffBezanson/gists{/gist_id}","starred_url":"https://api.github.com/users/JeffBezanson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JeffBezanson/subscriptions","organizations_url":"https://api.github.com/users/JeffBezanson/orgs","repos_url":"https://api.github.com/users/JeffBezanson/repos","events_url":"https://api.github.com/users/JeffBezanson/events{/privacy}","received_events_url":"https://api.github.com/users/JeffBezanson/received_events","type":"User","site_admin":false},"open_issues":171,"closed_issues":55,"state":"open","created_at":"2015-09-09T16:35:16Z","updated_at":"2016-11-10T17:38:54Z","due_on":"2017-01-31T00:00:00Z","closed_at":null},"comments":8,"created_at":"2014-01-03T01:46:02Z","updated_at":"2016-11-10T17:53:17Z","closed_at":null,"body":"## 1. Inconsistent logic between `lexcmp` and `nextfloat`\n\n``` julia\njulia> nextfloat(Inf)\nNaN\n\njulia> lexcmp(Inf,NaN)\nERROR: InexactError()\n in lexcmp at operators.jl:32\n\njulia> lexcmp(Inf,Inf)\nERROR: InexactError()\n in lexcmp at operators.jl:32\n```\n\nGiven the definition of `lexcmp` according to the help text, throwing an error is the right thing to do given that `>`, `==` and `<` are all supposed to be false when either operand is a `NaN` and so none of the standard return values (1, 0, -1) can be correct. However, it probably shouldn't throw an `InexactError`, but something else instead (probably `DomainError`).\n\nIn contrast, I don't see a meaningful sense in which `NaN` is the \"next\" number after `Inf`. The standard rule for computing with floating-point `Inf`s is to interpret it as a limit, in which case the correct result of `nextfloat(Inf)` should be `Inf` and not `NaN` (and similarly `prevfloat(-Inf)` returning `-Inf`. (Going by this rule, `lexcmp(Inf,Inf)` does correctly fail since there is a coalescence of `x<x+eps()`, `x==x+0` and `x>x-eps()` as x->`Inf`, so that there is no single limiting value.)\n## 2. Inconsistent behavior of `nextfloat` and `prevfloat` at different precisions\n\nIf we take the argument in the preceding paragraph to be correct, then in the following, only `nextfloat(Inf16)` is correct:\n\n``` julia\n julia> nextfloat(Inf) #should be Inf\nNaN\n\njulia> nextfloat(Inf32) #should be Inf32\nNaN32\n\njulia> nextfloat(Inf16) #should be Inf16\nInf16\n\njulia> prevfloat(-Inf) #should be -Inf\nNaN\n\njulia> prevfloat(-Inf32) #should be -Inf32\nNaN32\n\njulia> prevfloat(-Inf16) #should be -Inf16\nInf16\n```\n"},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/259759762","html_url":"https://github.com/JuliaLang/julia/issues/5290#issuecomment-259759762","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/5290","id":259759762,"user":{"login":"StefanKarpinski","id":153596,"avatar_url":"https://avatars.githubusercontent.com/u/153596?v=3","gravatar_id":"","url":"https://api.github.com/users/StefanKarpinski","html_url":"https://github.com/StefanKarpinski","followers_url":"https://api.github.com/users/StefanKarpinski/followers","following_url":"https://api.github.com/users/StefanKarpinski/following{/other_user}","gists_url":"https://api.github.com/users/StefanKarpinski/gists{/gist_id}","starred_url":"https://api.github.com/users/StefanKarpinski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StefanKarpinski/subscriptions","organizations_url":"https://api.github.com/users/StefanKarpinski/orgs","repos_url":"https://api.github.com/users/StefanKarpinski/repos","events_url":"https://api.github.com/users/StefanKarpinski/events{/privacy}","received_events_url":"https://api.github.com/users/StefanKarpinski/received_events","type":"User","site_admin":false},"created_at":"2016-11-10T17:53:17Z","updated_at":"2016-11-10T17:53:17Z","body":"The `nextfloat` and `prevfloat` behavior seems to have been fixed already.\r\n\r\nHere's one option for the comparison functions:\r\n\r\n- `cmp` and should match `isless` behavior for floats\r\n- `lexcmp` should match `lexless` which should use `isless` for floats\r\n\r\n"}}
{"actor":{"display_login":"StefanKarpinski"}}