Chromium Code Reviews| Index: runtime/lib/math_patch.dart |
| diff --git a/runtime/lib/math_patch.dart b/runtime/lib/math_patch.dart |
| index 0612d3db2ff7731f55241be980faac219b1b3497..e407633e4f360815e4a55920d984bcacf5b92704 100644 |
| --- a/runtime/lib/math_patch.dart |
| +++ b/runtime/lib/math_patch.dart |
| @@ -68,6 +68,15 @@ class _Random implements Random { |
| return result; |
| } |
| +int nextIntRange(int min, int max) { |
| + int range = max - min; |
| + if (range <= 0) { |
|
floitsch
2013/11/18 13:36:03
Doesn't test if max or min is negative.
|
| + throw new ArgumentError("min is greater then or equal to max"); |
|
floitsch
2013/11/18 13:36:03
Would be nice to have the values in the error mess
|
| + } |
| + range = nextInt(range); |
|
floitsch
2013/11/18 13:36:03
I wouldn't have called the result of the random-ca
|
| + return min + range; |
| + } |
| + |
| double nextDouble() { |
| return ((nextInt(1 << 26) << 27) + nextInt(1 << 27)) / _POW2_53_D; |
| } |