| 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 import "dart:typed_data"; | 5 import "dart:typed_data"; |
| 6 | 6 |
| 7 // A VM patch of the dart:math library. | 7 // A VM patch of the dart:math library. |
| 8 |
| 9 // If [x] is an [int] and [exponent] is a non-negative [int], the result is |
| 10 // an [int], otherwise the result is a [double]. |
| 8 patch num pow(num x, num exponent) { | 11 patch num pow(num x, num exponent) { |
| 9 if (exponent is int) { | 12 if ((x is int) && (exponent is int) && (exponent >= 0)) { |
| 10 return x.pow(exponent); | 13 return x.pow(exponent); |
| 11 } | 14 } |
| 12 // Double.pow will call exponent.toDouble(). | 15 // Double.pow will call exponent.toDouble(). |
| 13 return x.toDouble().pow(exponent); | 16 return x.toDouble().pow(exponent); |
| 14 } | 17 } |
| 15 | 18 |
| 16 patch double atan2(num a, num b) => _atan2(a.toDouble(), b.toDouble()); | 19 patch double atan2(num a, num b) => _atan2(a.toDouble(), b.toDouble()); |
| 17 patch double sin(num value) => _sin(value.toDouble()); | 20 patch double sin(num value) => _sin(value.toDouble()); |
| 18 patch double cos(num value) => _cos(value.toDouble()); | 21 patch double cos(num value) => _cos(value.toDouble()); |
| 19 patch double tan(num value) => _tan(value.toDouble()); | 22 patch double tan(num value) => _tan(value.toDouble()); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 115 |
| 113 static int _nextSeed() { | 116 static int _nextSeed() { |
| 114 if (_prng == null) { | 117 if (_prng == null) { |
| 115 // TODO(iposva): Use system to get a random seed. | 118 // TODO(iposva): Use system to get a random seed. |
| 116 _prng = new Random(new DateTime.now().millisecondsSinceEpoch); | 119 _prng = new Random(new DateTime.now().millisecondsSinceEpoch); |
| 117 } | 120 } |
| 118 // Trigger the PRNG once to change the internal state. | 121 // Trigger the PRNG once to change the internal state. |
| 119 return _prng._nextInt32(); | 122 return _prng._nextInt32(); |
| 120 } | 123 } |
| 121 } | 124 } |
| OLD | NEW |