{"action":"created","issue":{"url":"https://api.github.com/repos/cogneco/ooc-kean/issues/508","labels_url":"https://api.github.com/repos/cogneco/ooc-kean/issues/508/labels{/name}","comments_url":"https://api.github.com/repos/cogneco/ooc-kean/issues/508/comments","events_url":"https://api.github.com/repos/cogneco/ooc-kean/issues/508/events","html_url":"https://github.com/cogneco/ooc-kean/issues/508","id":110202431,"number":508,"title":"modulo","user":{"login":"davidhesselbom","id":4319680,"avatar_url":"https://avatars.githubusercontent.com/u/4319680?v=3","gravatar_id":"","url":"https://api.github.com/users/davidhesselbom","html_url":"https://github.com/davidhesselbom","followers_url":"https://api.github.com/users/davidhesselbom/followers","following_url":"https://api.github.com/users/davidhesselbom/following{/other_user}","gists_url":"https://api.github.com/users/davidhesselbom/gists{/gist_id}","starred_url":"https://api.github.com/users/davidhesselbom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidhesselbom/subscriptions","organizations_url":"https://api.github.com/users/davidhesselbom/orgs","repos_url":"https://api.github.com/users/davidhesselbom/repos","events_url":"https://api.github.com/users/davidhesselbom/events{/privacy}","received_events_url":"https://api.github.com/users/davidhesselbom/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cogneco/ooc-kean/labels/help%20wanted","name":"help wanted","color":"159818"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2015-10-07T11:14:45Z","updated_at":"2015-10-07T12:03:59Z","closed_at":null,"body":"`Int modulo(Int)`, defined in `math.ooc`, behaves oddly.\r\n\r\n```ooc\r\nimport math\r\n\r\n(5 % 3) toString() println() // outputs 2.\r\n(5 % -3) toString() println() // also outputs 2.\r\n(-5 % 3) toString() println() // outputs -2, but should output 1. \r\n// Too bad, but that's how the operator works in C.\r\n(-5 % -3) toString() println() // also outputs -2.\r\n\r\n(5 modulo(3)) toString() println() // outputs 2, as expected\r\n(5 modulo(-3)) toString() println() // outputs 1. Is this correct?\r\n(-5 modulo(3)) toString() println() // outputs -2, but it should output 1. \r\n// Unlike the % operator, modulo() was written explicitly to handle this situation,\r\n// but it still doesn't work correctly.\r\n((-5) modulo(3)) toString() println() // outputs 1, which is what we want.\r\n// So... it's a matter of parsing.\r\n(-5 modulo(-3)) toString() println() // outputs -1. Is this correct?\r\n((-5) modulo(-3)) toString() println() // outputs 2. Is this correct?\r\n```\r\n\r\nWe're not going to change the behavior of the `%` operator, but the `modulo` function that we added should work the way we want it to. Currently, it doesn't for `-5 modulo(3)`, but what about the cases where the divisor is negative? Should `modulo` always return a positive number?"},"comment":{"url":"https://api.github.com/repos/cogneco/ooc-kean/issues/comments/146176153","html_url":"https://github.com/cogneco/ooc-kean/issues/508#issuecomment-146176153","issue_url":"https://api.github.com/repos/cogneco/ooc-kean/issues/508","id":146176153,"user":{"login":"davidhesselbom","id":4319680,"avatar_url":"https://avatars.githubusercontent.com/u/4319680?v=3","gravatar_id":"","url":"https://api.github.com/users/davidhesselbom","html_url":"https://github.com/davidhesselbom","followers_url":"https://api.github.com/users/davidhesselbom/followers","following_url":"https://api.github.com/users/davidhesselbom/following{/other_user}","gists_url":"https://api.github.com/users/davidhesselbom/gists{/gist_id}","starred_url":"https://api.github.com/users/davidhesselbom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidhesselbom/subscriptions","organizations_url":"https://api.github.com/users/davidhesselbom/orgs","repos_url":"https://api.github.com/users/davidhesselbom/repos","events_url":"https://api.github.com/users/davidhesselbom/events{/privacy}","received_events_url":"https://api.github.com/users/davidhesselbom/received_events","type":"User","site_admin":false},"created_at":"2015-10-07T12:03:59Z","updated_at":"2015-10-07T12:03:59Z","body":"I updated the first post, thanks for the `(-5)` find, @sebastianbaginski."}}