Skip to content

Commit 2c88287

Browse files
Adding absolute value
1 parent c7375be commit 2c88287

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 * (piEstimation - Math.PI) / 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)