Can't get Rust types correct -
use std::num::float; fn main() { in 1..101 { euler(i) } } fn euler(x: i32){ let n: i32 = x; let e: f64 = (1.0+(1.0/n)).powi(n); println!("euler's number n = {} {}", n, e); }
i have code , can't compile. i'm pretty new rust appreciated!
let's @ error message:
<anon>:11:28: 11:29 error: mismatched types: expected `_`, found `i32` (expected floating-point variable, found i32) [e0308] <anon>:11 let e: f64 = (1.0+(1.0/n)).powi(n); ^
here, rust has very good messages: need provide floating-point variable, not integral one:
let e: f64 = (1.0+(1.0/n f64)).powi(n); // here ^~~~~~~~
Comments
Post a Comment