| 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 // A VM patch of the dart:math library. | 5 // A VM patch of the dart:math library. |
| 6 patch num pow(num x, num exponent) { | 6 patch num pow(num x, num exponent) { |
| 7 if (exponent is int) { | 7 if (exponent is int) { |
| 8 return x.pow(exponent); | 8 return x.pow(exponent); |
| 9 } | 9 } |
| 10 // Double.pow will call exponent.toDouble(). | 10 // Double.pow will call exponent.toDouble(). |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 static const _POW2_53_D = 1.0 * (1 << 53); | 104 static const _POW2_53_D = 1.0 * (1 << 53); |
| 105 | 105 |
| 106 static const _A = 0xffffda61; | 106 static const _A = 0xffffda61; |
| 107 | 107 |
| 108 // Use a singleton Random object to get a new seed if no seed was passed. | 108 // Use a singleton Random object to get a new seed if no seed was passed. |
| 109 static var _prng = null; | 109 static var _prng = null; |
| 110 | 110 |
| 111 static int _nextSeed() { | 111 static int _nextSeed() { |
| 112 if (_prng == null) { | 112 if (_prng == null) { |
| 113 // TODO(iposva): Use system to get a random seed. | 113 // TODO(iposva): Use system to get a random seed. |
| 114 _prng = new Random(new Date.now().millisecondsSinceEpoch); | 114 _prng = new Random(new DateTime.now().millisecondsSinceEpoch); |
| 115 } | 115 } |
| 116 // Trigger the PRNG once to change the internal state. | 116 // Trigger the PRNG once to change the internal state. |
| 117 return _prng._nextInt32(); | 117 return _prng._nextInt32(); |
| 118 } | 118 } |
| 119 } | 119 } |
| OLD | NEW |