{"action":"created","issue":{"url":"https://api.github.com/repos/numpy/numpy/issues/5745","labels_url":"https://api.github.com/repos/numpy/numpy/issues/5745/labels{/name}","comments_url":"https://api.github.com/repos/numpy/numpy/issues/5745/comments","events_url":"https://api.github.com/repos/numpy/numpy/issues/5745/events","html_url":"https://github.com/numpy/numpy/issues/5745","id":66253604,"number":5745,"title":"uint64 converted silently to float64 when adding an int","user":{"login":"nasailja","id":6211073,"avatar_url":"https://avatars.githubusercontent.com/u/6211073?v=3","gravatar_id":"","url":"https://api.github.com/users/nasailja","html_url":"https://github.com/nasailja","followers_url":"https://api.github.com/users/nasailja/followers","following_url":"https://api.github.com/users/nasailja/following{/other_user}","gists_url":"https://api.github.com/users/nasailja/gists{/gist_id}","starred_url":"https://api.github.com/users/nasailja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nasailja/subscriptions","organizations_url":"https://api.github.com/users/nasailja/orgs","repos_url":"https://api.github.com/users/nasailja/repos","events_url":"https://api.github.com/users/nasailja/events{/privacy}","received_events_url":"https://api.github.com/users/nasailja/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-04T00:06:55Z","updated_at":"2015-04-04T02:02:40Z","closed_at":null,"body":"This code\r\n```\r\nimport numpy\r\na = numpy.zeros(1, dtype = numpy.uint64)[0]\r\nprint(type(a))\r\ni = 1\r\nprint(type(i))\r\na += i\r\nprint(type(a))\r\n```\r\nprints\r\n```\r\n<class 'numpy.uint64'>\r\n<class 'int'>\r\n<class 'numpy.float64'>\r\n```\r\nwhich was a big surprise for me. Why would adding an integer to uint64 result in a floating point value?"},"comment":{"url":"https://api.github.com/repos/numpy/numpy/issues/comments/89483091","html_url":"https://github.com/numpy/numpy/issues/5745#issuecomment-89483091","issue_url":"https://api.github.com/repos/numpy/numpy/issues/5745","id":89483091,"user":{"login":"nasailja","id":6211073,"avatar_url":"https://avatars.githubusercontent.com/u/6211073?v=3","gravatar_id":"","url":"https://api.github.com/users/nasailja","html_url":"https://github.com/nasailja","followers_url":"https://api.github.com/users/nasailja/followers","following_url":"https://api.github.com/users/nasailja/following{/other_user}","gists_url":"https://api.github.com/users/nasailja/gists{/gist_id}","starred_url":"https://api.github.com/users/nasailja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nasailja/subscriptions","organizations_url":"https://api.github.com/users/nasailja/orgs","repos_url":"https://api.github.com/users/nasailja/repos","events_url":"https://api.github.com/users/nasailja/events{/privacy}","received_events_url":"https://api.github.com/users/nasailja/received_events","type":"User","site_admin":false},"created_at":"2015-04-04T02:02:40Z","updated_at":"2015-04-04T02:02:40Z","body":"Hmm 0x123...def is only about 2**61 which seems to fit into a regular int:\r\n```\r\n>>> 0x1234567890abcdef\r\n1311768467294899695\r\n>>> 2**60\r\n1152921504606846976\r\n>>> 2**61\r\n2305843009213693952\r\n>>> 2**62\r\n4611686018427387904\r\n>>> 2**63\r\n9223372036854775808L\r\n```\r\nso 64 bits should be enough whether the number is signed or not. At least for me a regular integer is able to represent all positive values that are supposed to fit into it (on x86_64):\r\n```\r\n>>> 0x7fffffffffffffff\r\n9223372036854775807\r\n>>> 0x8000000000000000\r\n9223372036854775808L\r\n```\r\n\r\nThis behavior also seems odd:\r\n```\r\n>>> numpy.uint64(0x7ffffffffffffffe) - 2**63\r\n-2L\r\n>>> numpy.uint64(0x7ffffffffffffffe) - 2**62\r\n4.6116860184273879e+18\r\n>>> numpy.uint64(0x7ffffffffffffffe) - 2.0**63\r\n0.0\r\n```\r\nI guess 0x7f...f rounds to the same value as ```2**63``` when converted to floating point, so the case of adding to a standard floating point value makes sense but what is happening with ```2**62``` and how can that be considered not a bug?"}}