| 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 part of the dart:math library. | 5 // A part of the dart:math library. |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A random number generator. The default implementation supplies a stream of | 8 * A random number generator. The default implementation supplies a stream of |
| 9 * pseudo-random bits which is not suitable for cryptographic purposes. | 9 * pseudo-random bits which is not suitable for cryptographic purposes. |
| 10 */ | 10 */ |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 static final _POW2_32 = 1 << 32; | 91 static final _POW2_32 = 1 << 32; |
| 92 static final _POW2_53_D = 1.0 * (1 << 53); | 92 static final _POW2_53_D = 1.0 * (1 << 53); |
| 93 | 93 |
| 94 static final _A = 0xffffda61; | 94 static final _A = 0xffffda61; |
| 95 | 95 |
| 96 var _state; | 96 var _state; |
| 97 | 97 |
| 98 int _nextSeed() { | 98 int _nextSeed() { |
| 99 if (_prng == null) { | 99 if (_prng == null) { |
| 100 // TODO(iposva): Use system to get a random seed. | 100 // TODO(iposva): Use system to get a random seed. |
| 101 _prng = new _Random(new Date.now().value); | 101 _prng = new _Random(new Date.now().millisecondsSinceEpoch); |
| 102 } | 102 } |
| 103 // Trigger the PRNG once to change the internal state. | 103 // Trigger the PRNG once to change the internal state. |
| 104 _prng._nextInt32(); | 104 _prng._nextInt32(); |
| 105 return _prng._state; | 105 return _prng._state; |
| 106 } | 106 } |
| 107 | 107 |
| 108 static var _prng = null; | 108 static var _prng = null; |
| 109 } | 109 } |
| OLD | NEW |