Created
July 17, 2012 04:59
-
-
Save jld/3127268 to your computer and use it in GitHub Desktop.
Wait for rand::gen_f64 to generate a number greater than 1.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import rand::rng; | |
fn main() { | |
let mut count : u64 = 0; | |
let rng = rand::seeded_rng(~[17]); | |
loop { | |
let r = rng.gen_f64(); | |
if r > 1.0f64 { | |
io::println(#fmt("%s > 1.0 (after %? tries)", | |
float::to_str_exact(r as float, 16), count)); | |
break; | |
} | |
count += 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment