{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/9283","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/9283/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/9283/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/9283/events","html_url":"https://github.com/JuliaLang/julia/issues/9283","id":51449388,"number":9283,"title":"Euclidean division: `div`, `rem` and friends","user":{"login":"simonbyrne","id":1692009,"avatar_url":"https://avatars.githubusercontent.com/u/1692009?v=3","gravatar_id":"","url":"https://api.github.com/users/simonbyrne","html_url":"https://github.com/simonbyrne","followers_url":"https://api.github.com/users/simonbyrne/followers","following_url":"https://api.github.com/users/simonbyrne/following{/other_user}","gists_url":"https://api.github.com/users/simonbyrne/gists{/gist_id}","starred_url":"https://api.github.com/users/simonbyrne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simonbyrne/subscriptions","organizations_url":"https://api.github.com/users/simonbyrne/orgs","repos_url":"https://api.github.com/users/simonbyrne/repos","events_url":"https://api.github.com/users/simonbyrne/events{/privacy}","received_events_url":"https://api.github.com/users/simonbyrne/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/JuliaLang/julia/labels/maths","name":"maths","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":23,"created_at":"2014-12-09T16:35:47Z","updated_at":"2015-04-28T11:24:54Z","closed_at":null,"body":"For any two real numbers `x` and `y`, Euclidean division is the problem of finding an integer `q` (the quotient) and number `r` (the remainder, on  an interval of length `abs(y)`) such that\r\n```\r\nx = q*y + r\r\n```\r\n\r\nWe currently offer 3 methods for computing `q` and `r`\r\n\r\n| quotient function | equivalent exact expression | remainder  function |\r\n|------|-------|-------|\r\n| `div(x,y)` | `trunc(x/y)` | `rem(x,y)` |\r\n| `fld(x,y)` | `floor(x/y)` | `mod(x,y)` |\r\n| `cld(x,y)` | `ceil(x/y)` | `mod(x,-y)` |\r\n\r\nUnfortunately, none of these actually correspond to the `remainder` function in the IEEE-754 standard, which is defined as the remainder after `x/y` has been rounded to the nearest integer, ties to even (this is also the [`remainder`](http://www.cplusplus.com/reference/cmath/remainder/) function in C). \r\n\r\nOne idea would be implement these by dispatching `div`, `rem` and `divrem` on `RoundingMode` (similar to what I proposed in https://github.com/JuliaLang/julia/issues/8750#issuecomment-65948396.\r\n\r\nAnother thing that would be useful to have, is something like C's [`remquo`](http://www.cplusplus.com/reference/cmath/remquo/) function, which returns the congruent modulo of the quotient, which is handy for massive range reductions (e.g. for `sind`).\r\n"},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/97025858","html_url":"https://github.com/JuliaLang/julia/issues/9283#issuecomment-97025858","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/9283","id":97025858,"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":"2015-04-28T11:24:54Z","updated_at":"2015-04-28T11:24:54Z","body":"How would a three-bit unsigned integer type help?"}}