Skip to content

Commit 9971284

Browse files
Wesley-Arringtonjiegillet
authored andcommitted
Updating Percent Error Calculation (#328)
1 parent 4736615 commit 9971284

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

contents/monte_carlo_integration/code/swift/monte_carlo.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func monteCarlo(n: Int) -> Double {
3838
func main() {
3939
let piEstimate = monteCarlo(n: 10000)
4040
print("Pi estimate is: ", piEstimate)
41-
print("Percent error is: \(100*(Double.pi - piEstimate)/Double.pi)%")
41+
print("Percent error is: \(100 * abs(piEstimate - Double.pi)/Double.pi)%")
4242
}
4343

4444

0 commit comments

Comments
 (0)