OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // Test that the default PRNG does converge towards Pi when doing a Monte Carlo | 5 // Test that the default PRNG does converge towards Pi when doing a Monte Carlo |
6 // simulation. | 6 // simulation. |
7 | 7 |
8 // Library tag to allow Dartium to run the test. | 8 // Library tag to allow Dartium to run the test. |
9 library pi_test; | 9 library pi_test; |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 inside++; | 43 inside++; |
44 } else { | 44 } else { |
45 outside++; | 45 outside++; |
46 } | 46 } |
47 } | 47 } |
48 // Mmmmh, Pie! | 48 // Mmmmh, Pie! |
49 var pie = 4.0 * (inside / (inside + outside)); | 49 var pie = 4.0 * (inside / (inside + outside)); |
50 print("$pie"); | 50 print("$pie"); |
51 Expect.isTrue(((PI - 0.009) < pie) && (pie < (PI + 0.009))); | 51 Expect.isTrue(((PI - 0.009) < pie) && (pie < (PI + 0.009))); |
52 } | 52 } |
OLD | NEW |