{"action":"created","issue":{"url":"https://api.github.com/repos/qorelanguage/qore/issues/874","repository_url":"https://api.github.com/repos/qorelanguage/qore","labels_url":"https://api.github.com/repos/qorelanguage/qore/issues/874/labels{/name}","comments_url":"https://api.github.com/repos/qorelanguage/qore/issues/874/comments","events_url":"https://api.github.com/repos/qorelanguage/qore/issues/874/events","html_url":"https://github.com/qorelanguage/qore/issues/874","id":155325318,"number":874,"title":"add bitLength / bitCount method to int type","user":{"login":"gamato","id":480379,"avatar_url":"https://avatars.githubusercontent.com/u/480379?v=3","gravatar_id":"","url":"https://api.github.com/users/gamato","html_url":"https://github.com/gamato","followers_url":"https://api.github.com/users/gamato/followers","following_url":"https://api.github.com/users/gamato/following{/other_user}","gists_url":"https://api.github.com/users/gamato/gists{/gist_id}","starred_url":"https://api.github.com/users/gamato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gamato/subscriptions","organizations_url":"https://api.github.com/users/gamato/orgs","repos_url":"https://api.github.com/users/gamato/repos","events_url":"https://api.github.com/users/gamato/events{/privacy}","received_events_url":"https://api.github.com/users/gamato/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/qorelanguage/qore/labels/feature","name":"feature","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-17T18:11:39Z","updated_at":"2016-05-17T18:25:29Z","closed_at":null,"body":"Bit-length is the number of binary digits, called bits, necessary to represent an integer in the binary number system.\r\n\r\nIt seems bitLength() is better (that is more standard) name than bitCount() -- https://en.wikipedia.org/wiki/Bit-length"},"comment":{"url":"https://api.github.com/repos/qorelanguage/qore/issues/comments/219809115","html_url":"https://github.com/qorelanguage/qore/issues/874#issuecomment-219809115","issue_url":"https://api.github.com/repos/qorelanguage/qore/issues/874","id":219809115,"user":{"login":"gamato","id":480379,"avatar_url":"https://avatars.githubusercontent.com/u/480379?v=3","gravatar_id":"","url":"https://api.github.com/users/gamato","html_url":"https://github.com/gamato","followers_url":"https://api.github.com/users/gamato/followers","following_url":"https://api.github.com/users/gamato/following{/other_user}","gists_url":"https://api.github.com/users/gamato/gists{/gist_id}","starred_url":"https://api.github.com/users/gamato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gamato/subscriptions","organizations_url":"https://api.github.com/users/gamato/orgs","repos_url":"https://api.github.com/users/gamato/repos","events_url":"https://api.github.com/users/gamato/events{/privacy}","received_events_url":"https://api.github.com/users/gamato/received_events","type":"User","site_admin":false},"created_at":"2016-05-17T18:25:29Z","updated_at":"2016-05-17T18:25:29Z","body":"Here's a simple implementation:\r\n```\r\nint bit_length (int i) {\r\n    if (i == 0)\r\n        return 0;\r\n    return int(logb(i))+1;\r\n}\r\n```\r\nThis would likely fail for large numbers, though, due to loss of digits / precision in float calculations."}}