{"action":"created","issue":{"url":"https://api.github.com/repos/Azimer/AziAudio/issues/66","labels_url":"https://api.github.com/repos/Azimer/AziAudio/issues/66/labels{/name}","comments_url":"https://api.github.com/repos/Azimer/AziAudio/issues/66/comments","events_url":"https://api.github.com/repos/Azimer/AziAudio/issues/66/events","html_url":"https://github.com/Azimer/AziAudio/issues/66","id":76063240,"number":66,"title":"Can `vscale' be shifted by a negative amount?","user":{"login":"cxd4","id":1396303,"avatar_url":"https://avatars.githubusercontent.com/u/1396303?v=3","gravatar_id":"","url":"https://api.github.com/users/cxd4","html_url":"https://github.com/cxd4","followers_url":"https://api.github.com/users/cxd4/followers","following_url":"https://api.github.com/users/cxd4/following{/other_user}","gists_url":"https://api.github.com/users/cxd4/gists{/gist_id}","starred_url":"https://api.github.com/users/cxd4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cxd4/subscriptions","organizations_url":"https://api.github.com/users/cxd4/orgs","repos_url":"https://api.github.com/users/cxd4/repos","events_url":"https://api.github.com/users/cxd4/events{/privacy}","received_events_url":"https://api.github.com/users/cxd4/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-05-13T17:30:03Z","updated_at":"2015-05-14T18:16:50Z","closed_at":null,"body":"During one of my last PRs I noticed this line 3 times throughout ADPCM:\r\nhttps://github.com/cxd4/AziAudio/blob/e189652ff03899f954278a6ab79c9ea598dede5a/AziAudio/ABI_Adpcm.cpp#L89\r\n\r\nThe comment below it reads:\r\n```c\r\n// so this appears to be a fractional scale based\r\n// on the 12 based inverse of the scale value. note\r\n// that this could be negative, in which case we do\r\n// not use the calculated vscale value... see the\r\n// if(code>12) check below\r\n```\r\nThis comment leads me to consider two questions.\r\n* Where is this `if (code > 12)` check?  There doesn't seem to be one throughout the file, which means that if `code` was 12, it doesn't seem prevented that we might be shifting right by a negative.\r\n* Why is it **12**, exactly?  The actual shift amount here reads `((12 - code) - 1)`, which simplifies algebraically to `(11 - code)`; therefore the only ways through which the shift amount would not be negative is `if (code > 11)`, not `if (code > 12)`, is false."},"comment":{"url":"https://api.github.com/repos/Azimer/AziAudio/issues/comments/102125280","html_url":"https://github.com/Azimer/AziAudio/issues/66#issuecomment-102125280","issue_url":"https://api.github.com/repos/Azimer/AziAudio/issues/66","id":102125280,"user":{"login":"Azimer","id":12119720,"avatar_url":"https://avatars.githubusercontent.com/u/12119720?v=3","gravatar_id":"","url":"https://api.github.com/users/Azimer","html_url":"https://github.com/Azimer","followers_url":"https://api.github.com/users/Azimer/followers","following_url":"https://api.github.com/users/Azimer/following{/other_user}","gists_url":"https://api.github.com/users/Azimer/gists{/gist_id}","starred_url":"https://api.github.com/users/Azimer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azimer/subscriptions","organizations_url":"https://api.github.com/users/Azimer/orgs","repos_url":"https://api.github.com/users/Azimer/repos","events_url":"https://api.github.com/users/Azimer/events{/privacy}","received_events_url":"https://api.github.com/users/Azimer/received_events","type":"User","site_admin":false},"created_at":"2015-05-14T18:16:50Z","updated_at":"2015-05-14T18:16:50Z","body":"I disagree with it being less maintainable since you are basically checking the value of code.  I do agree however, assert is for debugging and can be removed by the preprocessor.  In this case there's no gain in removing it from where it is for release builds.  We're good."}}