Skip to content

Commit acc0289

Browse files
Gathrosjune128
authored andcommitted
Fixing percent error in monte_carlo.rs (#381)
* fixing percent error in monte_carlo.rs * small change to monte_carlo.rs
1 parent 40d37dd commit acc0289

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

contents/monte_carlo_integration/code/rust/monte_carlo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ fn monte_carlo(n: i64) -> f64 {
2626
fn main() {
2727
let pi_estimate = monte_carlo(10000000);
2828

29-
println!("Percent error is {:.3}%", (100.0 * (PI - pi_estimate) / PI));
29+
println!("Percent error is {:.3}%", (100.0 * (pi_estimate - PI).abs() / PI));
3030
}

0 commit comments

Comments
 (0)