{"action":"created","issue":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/4792","repository_url":"https://api.github.com/repos/crystal-lang/crystal","labels_url":"https://api.github.com/repos/crystal-lang/crystal/issues/4792/labels{/name}","comments_url":"https://api.github.com/repos/crystal-lang/crystal/issues/4792/comments","events_url":"https://api.github.com/repos/crystal-lang/crystal/issues/4792/events","html_url":"https://github.com/crystal-lang/crystal/issues/4792","id":248146855,"number":4792,"title":"Make Math.sqrt turn BigInt into BigFloat instead of Float64?","user":{"login":"Qwerp-Derp","id":14177193,"avatar_url":"https://avatars3.githubusercontent.com/u/14177193?v=4","gravatar_id":"","url":"https://api.github.com/users/Qwerp-Derp","html_url":"https://github.com/Qwerp-Derp","followers_url":"https://api.github.com/users/Qwerp-Derp/followers","following_url":"https://api.github.com/users/Qwerp-Derp/following{/other_user}","gists_url":"https://api.github.com/users/Qwerp-Derp/gists{/gist_id}","starred_url":"https://api.github.com/users/Qwerp-Derp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Qwerp-Derp/subscriptions","organizations_url":"https://api.github.com/users/Qwerp-Derp/orgs","repos_url":"https://api.github.com/users/Qwerp-Derp/repos","events_url":"https://api.github.com/users/Qwerp-Derp/events{/privacy}","received_events_url":"https://api.github.com/users/Qwerp-Derp/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-08-05T00:54:23Z","updated_at":"2017-08-05T07:30:31Z","closed_at":null,"body":"I have this code:\r\n\r\n```crystal\r\nrequire \"big_int\"\r\nMath.sqrt(BigInt.new(\"10000\"))\r\n```\r\n\r\nWhen run on `crystal play`, it outputs `100`, which is the expected result, but the type of the output is `Float64`.\r\n\r\nIf I want to work with larger numbers and square-rooting these numbers, I want to have arbitrary precision for those as well. Wouldn't it make sense to make `Math.sqrt` turn a `BigInt` into a `BigFloat`?\r\n\r\nThe only problem with this proposal is when to stop calculating the square root of the number - I'm not really sure how to address that, but simply using `Float64` seems restrictive.\r\n"},"comment":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/comments/320424142","html_url":"https://github.com/crystal-lang/crystal/issues/4792#issuecomment-320424142","issue_url":"https://api.github.com/repos/crystal-lang/crystal/issues/4792","id":320424142,"user":{"login":"straight-shoota","id":466378,"avatar_url":"https://avatars0.githubusercontent.com/u/466378?v=4","gravatar_id":"","url":"https://api.github.com/users/straight-shoota","html_url":"https://github.com/straight-shoota","followers_url":"https://api.github.com/users/straight-shoota/followers","following_url":"https://api.github.com/users/straight-shoota/following{/other_user}","gists_url":"https://api.github.com/users/straight-shoota/gists{/gist_id}","starred_url":"https://api.github.com/users/straight-shoota/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/straight-shoota/subscriptions","organizations_url":"https://api.github.com/users/straight-shoota/orgs","repos_url":"https://api.github.com/users/straight-shoota/repos","events_url":"https://api.github.com/users/straight-shoota/events{/privacy}","received_events_url":"https://api.github.com/users/straight-shoota/received_events","type":"User","site_admin":false},"created_at":"2017-08-05T07:30:31Z","updated_at":"2017-08-05T07:30:31Z","body":"Currently `Math` has no special implementations for big numbers. `Math.sqrt(BigInt)` just converts big int to float. That's why the return value is also `Float64`."}}
{"actor":{"display_login":"straight-shoota"}}