]> git.lizzy.rs Git - rust.git/blob - src/etc/test-float-parse/_common.rs
Rollup merge of #53093 - 0e4ef622:issue-52169-fix, r=petrochenkov
[rust.git] / src / etc / test-float-parse / _common.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 use std::io;
12 use std::io::prelude::*;
13 use std::mem::transmute;
14
15 // Nothing up my sleeve: Just (PI - 3) in base 16.
16 #[allow(dead_code)]
17 pub const SEED: [u32; 3] = [0x243f_6a88, 0x85a3_08d3, 0x1319_8a2e];
18
19 pub fn validate(text: &str) {
20     let mut out = io::stdout();
21     let x: f64 = text.parse().unwrap();
22     let f64_bytes: u64 = unsafe { transmute(x) };
23     let x: f32 = text.parse().unwrap();
24     let f32_bytes: u32 = unsafe { transmute(x) };
25     writeln!(&mut out, "{:016x} {:08x} {}", f64_bytes, f32_bytes, text).unwrap();
26 }