Skip to content

Commit eb5b72f

Browse files
author
Robin Kruppe
committed
---
yaml --- r: 233337 b: refs/heads/beta c: 82dbc2e h: refs/heads/master i: 233335: ed9675d v: v3
1 parent 152d24a commit eb5b72f

File tree

12 files changed

+665
-1
lines changed

12 files changed

+665
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: ba792a4baa856d83c3001afa181db91c5b4c9732
26+
refs/heads/beta: 82dbc2ea619cbfc98ca9ad2f9e06a5acd294cbe3
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 370fe2786109360f7c35b8ba552b83b773dd71d6
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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: String) {
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+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
mod _common;
12+
13+
use _common::validate;
14+
15+
fn main() {
16+
let mut pow = vec![];
17+
for i in 0..63 {
18+
pow.push(1u64 << i);
19+
}
20+
for a in &pow {
21+
for b in &pow {
22+
for c in &pow {
23+
validate((a | b | c).to_string());
24+
}
25+
}
26+
}
27+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
mod _common;
12+
13+
use _common::validate;
14+
15+
fn main() {
16+
for e in 300..310 {
17+
for i in 0..100000 {
18+
validate(format!("{}e{}", i, e));
19+
}
20+
}
21+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
#![feature(rand)]
12+
13+
extern crate rand;
14+
15+
mod _common;
16+
17+
use std::char;
18+
use rand::{IsaacRng, Rng, SeedableRng};
19+
use rand::distributions::{Range, Sample};
20+
use _common::{validate, SEED};
21+
22+
fn main() {
23+
let mut rnd = IsaacRng::from_seed(&SEED);
24+
let mut range = Range::new(0, 10);
25+
for _ in 0..5_000_000u64 {
26+
let num_digits = rnd.gen_range(100, 300);
27+
let digits = gen_digits(num_digits, &mut range, &mut rnd);
28+
validate(digits);
29+
}
30+
}
31+
32+
fn gen_digits<R: Rng>(n: u32, range: &mut Range<u32>, rnd: &mut R) -> String {
33+
let mut s = String::new();
34+
for _ in 0..n {
35+
let digit = char::from_digit(range.sample(rnd), 10).unwrap();
36+
s.push(digit);
37+
}
38+
s
39+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
#![feature(rand)]
12+
13+
extern crate rand;
14+
15+
mod _common;
16+
17+
use _common::{validate, SEED};
18+
use rand::{IsaacRng, Rng, SeedableRng};
19+
use std::mem::transmute;
20+
21+
fn main() {
22+
let mut rnd = IsaacRng::from_seed(&SEED);
23+
let mut i = 0;
24+
while i < 10_000_000 {
25+
let bits = rnd.next_u64();
26+
let x: f64 = unsafe { transmute(bits) };
27+
if x.is_finite() {
28+
validate(format!("{:e}", x));
29+
i += 1;
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)