Skip to content

Commit 8b49852

Browse files
authored
Merge pull request #371 from CDsigma/updatingMonteCarloJava
Updating Monte Carlo in Java
2 parents ff753eb + 2c88287 commit 8b49852

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

contents/monte_carlo_integration/code/java/MonteCarlo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class MonteCarlo {
66
public static void main(String[] args) {
77
double piEstimation = monteCarlo(1000);
88
System.out.println("Estimated pi value: " + piEstimation);
9-
System.out.printf("Percent error: " + 100 * (Math.PI - piEstimation) / Math.PI);
9+
System.out.printf("Percent error: " + 100 * Math.abs(piEstimation - Math.PI) / Math.PI);
1010
}
1111

1212
//function to check whether point (x,y) is in unit circle

0 commit comments

Comments
 (0)