{"action":"created","issue":{"url":"https://api.github.com/repos/micropython/micropython/issues/1063","labels_url":"https://api.github.com/repos/micropython/micropython/issues/1063/labels{/name}","comments_url":"https://api.github.com/repos/micropython/micropython/issues/1063/comments","events_url":"https://api.github.com/repos/micropython/micropython/issues/1063/events","html_url":"https://github.com/micropython/micropython/pull/1063","id":54211173,"number":1063,"title":"py: Convert float to correct int type","user":{"login":"doogle","id":1585181,"avatar_url":"https://avatars.githubusercontent.com/u/1585181?v=3","gravatar_id":"","url":"https://api.github.com/users/doogle","html_url":"https://github.com/doogle","followers_url":"https://api.github.com/users/doogle/followers","following_url":"https://api.github.com/users/doogle/following{/other_user}","gists_url":"https://api.github.com/users/doogle/gists{/gist_id}","starred_url":"https://api.github.com/users/doogle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doogle/subscriptions","organizations_url":"https://api.github.com/users/doogle/orgs","repos_url":"https://api.github.com/users/doogle/repos","events_url":"https://api.github.com/users/doogle/events{/privacy}","received_events_url":"https://api.github.com/users/doogle/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-01-13T16:04:13Z","updated_at":"2015-01-13T16:30:35Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/micropython/micropython/pulls/1063","html_url":"https://github.com/micropython/micropython/pull/1063","diff_url":"https://github.com/micropython/micropython/pull/1063.diff","patch_url":"https://github.com/micropython/micropython/pull/1063.patch"},"body":"A redo of pull request #1047, to address issue #1042 (currently worked around by ad2307c92c15f0aa90dbd0741fd2538719d0b5e1).\r\n\r\nThe approach I used in the end allowed for the full range of small ints to be used. Exceptions are now raised in the event of an overflow as well.\r\n\r\nAs discussed, `fpclassify()` is used to test for inf and NaN, and the new `mp_classify_fp_as_int()` function is used for all other values.\r\n\r\nThe code size could be reduced slightly by not caring so much about ensuring that the full range of small ints are used, but (in the case of `MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_MPZ`), this would also result in exceptions being raised when the number could be converted to an int (which I would count as a bug)."},"comment":{"url":"https://api.github.com/repos/micropython/micropython/issues/comments/69772941","html_url":"https://github.com/micropython/micropython/pull/1063#issuecomment-69772941","issue_url":"https://api.github.com/repos/micropython/micropython/issues/1063","id":69772941,"user":{"login":"doogle","id":1585181,"avatar_url":"https://avatars.githubusercontent.com/u/1585181?v=3","gravatar_id":"","url":"https://api.github.com/users/doogle","html_url":"https://github.com/doogle","followers_url":"https://api.github.com/users/doogle/followers","following_url":"https://api.github.com/users/doogle/following{/other_user}","gists_url":"https://api.github.com/users/doogle/gists{/gist_id}","starred_url":"https://api.github.com/users/doogle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doogle/subscriptions","organizations_url":"https://api.github.com/users/doogle/orgs","repos_url":"https://api.github.com/users/doogle/repos","events_url":"https://api.github.com/users/doogle/events{/privacy}","received_events_url":"https://api.github.com/users/doogle/received_events","type":"User","site_admin":false},"created_at":"2015-01-13T16:30:35Z","updated_at":"2015-01-13T16:30:35Z","body":"Good point @stinos. Corner cases depend on the configured value of `MICROPY_LONGINT_IMPL` and whether the build is 32-bit or 64-bit. Is there a way of detecting this?"}}