{"action":"created","issue":{"url":"https://api.github.com/repos/supercollider/supercollider/issues/2378","repository_url":"https://api.github.com/repos/supercollider/supercollider","labels_url":"https://api.github.com/repos/supercollider/supercollider/issues/2378/labels{/name}","comments_url":"https://api.github.com/repos/supercollider/supercollider/issues/2378/comments","events_url":"https://api.github.com/repos/supercollider/supercollider/issues/2378/events","html_url":"https://github.com/supercollider/supercollider/issues/2378","id":181096667,"number":2378,"title":"Unary operator trunc gives incorrect results for negative numbers","user":{"login":"Beechside","id":5500886,"avatar_url":"https://avatars.githubusercontent.com/u/5500886?v=3","gravatar_id":"","url":"https://api.github.com/users/Beechside","html_url":"https://github.com/Beechside","followers_url":"https://api.github.com/users/Beechside/followers","following_url":"https://api.github.com/users/Beechside/following{/other_user}","gists_url":"https://api.github.com/users/Beechside/gists{/gist_id}","starred_url":"https://api.github.com/users/Beechside/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Beechside/subscriptions","organizations_url":"https://api.github.com/users/Beechside/orgs","repos_url":"https://api.github.com/users/Beechside/repos","events_url":"https://api.github.com/users/Beechside/events{/privacy}","received_events_url":"https://api.github.com/users/Beechside/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-10-05T08:47:42Z","updated_at":"2016-10-05T13:56:09Z","closed_at":null,"body":"The unary operator trunc should always round towards zero.\r\n\r\n-3.3.trunc should give -3 but SC gives -4\r\n-3.3.trunc(0.25) should give -3.25 but SC gives -3.5\r\n\r\nI know of no language where trunc always rounds towards negative infinity so believe this to be a bug in SC.\r\n\r\nI realise that I can use -3.3.trunc(-1) and -3.3.trunc(-0.25) to get the correct results but that seems to be going against the \"standard\" definition of trunc."},"comment":{"url":"https://api.github.com/repos/supercollider/supercollider/issues/comments/251681814","html_url":"https://github.com/supercollider/supercollider/issues/2378#issuecomment-251681814","issue_url":"https://api.github.com/repos/supercollider/supercollider/issues/2378","id":251681814,"user":{"login":"vivid-synth","id":10969331,"avatar_url":"https://avatars.githubusercontent.com/u/10969331?v=3","gravatar_id":"","url":"https://api.github.com/users/vivid-synth","html_url":"https://github.com/vivid-synth","followers_url":"https://api.github.com/users/vivid-synth/followers","following_url":"https://api.github.com/users/vivid-synth/following{/other_user}","gists_url":"https://api.github.com/users/vivid-synth/gists{/gist_id}","starred_url":"https://api.github.com/users/vivid-synth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vivid-synth/subscriptions","organizations_url":"https://api.github.com/users/vivid-synth/orgs","repos_url":"https://api.github.com/users/vivid-synth/repos","events_url":"https://api.github.com/users/vivid-synth/events{/privacy}","received_events_url":"https://api.github.com/users/vivid-synth/received_events","type":"User","site_admin":false},"created_at":"2016-10-05T13:56:09Z","updated_at":"2016-10-05T13:56:09Z","body":"Other languages do agree with @Beechside's description:\r\n\r\nHaskell:\r\n```\r\n> truncate (-3.3)\r\n-3\r\n```\r\n\r\nRuby:\r\n```\r\nirb(main):003:0> -3.3.truncate\r\n=> -3\r\n```\r\n\r\nPython:\r\n```\r\n>>> import math\r\n>>> math.trunc(-3.3)\r\n-3\r\n```\r\n\r\nJavascript:\r\n```\r\nMath.trunc(-3.3)\r\n-3\r\n```\r\n\r\nI'm maybe not the best advocate because I don't use sclang as much as scsynth, but I'd be open to the idea of \"fixing\" how ```trunc``` works if there isn't much code that uses it with negative numbers, and if everyone is notified that it's changed. Not sure it's worth it on balance, but it's worth discussing."}}
{"actor":{"display_login":"vivid-synth"}}