{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/23505","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/23505/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/23505/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/23505/events","html_url":"https://github.com/rust-lang/rust/issues/23505","id":62860306,"number":23505,"title":"<f64 as FromStr> produces incorrect results in some cases","user":{"login":"JRoush","id":1007215,"avatar_url":"https://avatars.githubusercontent.com/u/1007215?v=3","gravatar_id":"","url":"https://api.github.com/users/JRoush","html_url":"https://github.com/JRoush","followers_url":"https://api.github.com/users/JRoush/followers","following_url":"https://api.github.com/users/JRoush/following{/other_user}","gists_url":"https://api.github.com/users/JRoush/gists{/gist_id}","starred_url":"https://api.github.com/users/JRoush/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JRoush/subscriptions","organizations_url":"https://api.github.com/users/JRoush/orgs","repos_url":"https://api.github.com/users/JRoush/repos","events_url":"https://api.github.com/users/JRoush/events{/privacy}","received_events_url":"https://api.github.com/users/JRoush/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-19T03:12:46Z","updated_at":"2015-03-19T15:57:07Z","closed_at":null,"body":"In at least one case (and presumably more), `FromStr::from_str()` produces a result that is off by one ulp.\r\n\r\nExample:\r\n\r\n    pub fn main() {\r\n        use std::str::FromStr;    \r\n        let literal: f64 = 0.123f64;\r\n        let fromstr: f64 = FromStr::from_str(\"0.123\").unwrap();\r\n        println!(\"Literal: {:16X}\", as_int(literal)); // Literal: 3FBF7CED916872B0\r\n        println!(\"FromStr: {:16X}\", as_int(fromstr)); // FromStr: 3FBF7CED916872B1\r\n        println!(\"Equal: {}\", literal == fromstr);    // Equal: false\r\n    }\r\n\r\n    pub fn as_int(f: f64) -> u64 {\r\n        unsafe{ std::mem::transmute::<f64,u64>(f) }\r\n    }\r\n\r\nHere the compiler produces the correct result for the literal value but the runtime parsing function produces a different, incorrect result.  The difference is tiny, but of course it is enough to cause problems :)\r\n\r\nFor the record, here is the output of `rustc --version --verbose` on my system:\r\n\r\n    rustc 1.0.0-nightly (30e1f9a1c 2015-03-14) (built 2015-03-15)\r\n    binary: rustc\r\n    commit-hash: 30e1f9a1c2bf7134135800bc9afd082773defadc\r\n    commit-date: 2015-03-14\r\n    build-date: 2015-03-15\r\n    host: x86_64-unknown-linux-gnu\r\n    release: 1.0.0-nightly"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/83642524","html_url":"https://github.com/rust-lang/rust/issues/23505#issuecomment-83642524","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/23505","id":83642524,"user":{"login":"JRoush","id":1007215,"avatar_url":"https://avatars.githubusercontent.com/u/1007215?v=3","gravatar_id":"","url":"https://api.github.com/users/JRoush","html_url":"https://github.com/JRoush","followers_url":"https://api.github.com/users/JRoush/followers","following_url":"https://api.github.com/users/JRoush/following{/other_user}","gists_url":"https://api.github.com/users/JRoush/gists{/gist_id}","starred_url":"https://api.github.com/users/JRoush/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JRoush/subscriptions","organizations_url":"https://api.github.com/users/JRoush/orgs","repos_url":"https://api.github.com/users/JRoush/repos","events_url":"https://api.github.com/users/JRoush/events{/privacy}","received_events_url":"https://api.github.com/users/JRoush/received_events","type":"User","site_admin":false},"created_at":"2015-03-19T15:57:07Z","updated_at":"2015-03-19T15:57:07Z","body":"@lifthrasiir Whoops, looks like you are right."}}