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 | 8 |
9 // If [x] is an [int] and [exponent] is a non-negative [int], the result is | 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]. | 10 // an [int], otherwise the result is a [double]. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 exponent >>= 1; | 50 exponent >>= 1; |
51 // Skip unnecessary operation (can overflow to Mint or Bigint). | 51 // Skip unnecessary operation (can overflow to Mint or Bigint). |
52 if (exponent != 0) { | 52 if (exponent != 0) { |
53 base *= base; | 53 base *= base; |
54 } | 54 } |
55 } | 55 } |
56 return result; | 56 return result; |
57 } | 57 } |
58 | 58 |
59 @patch double atan2(num a, num b) => _atan2(a.toDouble(), b.toDouble()); | 59 @patch double atan2(num a, num b) => _atan2(a.toDouble(), b.toDouble()); |
60 @patch double sin(num value) => _sin(value.toDouble()); | 60 @patch double sin(num x) => _sin(x.toDouble()); |
61 @patch double cos(num value) => _cos(value.toDouble()); | 61 @patch double cos(num x) => _cos(x.toDouble()); |
62 @patch double tan(num value) => _tan(value.toDouble()); | 62 @patch double tan(num x) => _tan(x.toDouble()); |
63 @patch double acos(num value) => _acos(value.toDouble()); | 63 @patch double acos(num x) => _acos(x.toDouble()); |
64 @patch double asin(num value) => _asin(value.toDouble()); | 64 @patch double asin(num x) => _asin(x.toDouble()); |
65 @patch double atan(num value) => _atan(value.toDouble()); | 65 @patch double atan(num x) => _atan(x.toDouble()); |
66 @patch double sqrt(num value) => _sqrt(value.toDouble()); | 66 @patch double sqrt(num x) => _sqrt(x.toDouble()); |
67 @patch double exp(num value) => _exp(value.toDouble()); | 67 @patch double exp(num x) => _exp(x.toDouble()); |
68 @patch double log(num value) => _log(value.toDouble()); | 68 @patch double log(num x) => _log(x.toDouble()); |
69 | 69 |
70 double _atan2(double a, double b) native "Math_atan2"; | 70 double _atan2(double a, double b) native "Math_atan2"; |
71 double _sin(double x) native "Math_sin"; | 71 double _sin(double x) native "Math_sin"; |
72 double _cos(double x) native "Math_cos"; | 72 double _cos(double x) native "Math_cos"; |
73 double _tan(double x) native "Math_tan"; | 73 double _tan(double x) native "Math_tan"; |
74 double _acos(double x) native "Math_acos"; | 74 double _acos(double x) native "Math_acos"; |
75 double _asin(double x) native "Math_asin"; | 75 double _asin(double x) native "Math_asin"; |
76 double _atan(double x) native "Math_atan"; | 76 double _atan(double x) native "Math_atan"; |
77 double _sqrt(double x) native "Math_sqrt"; | 77 double _sqrt(double x) native "Math_sqrt"; |
78 double _exp(double x) native "Math_exp"; | 78 double _exp(double x) native "Math_exp"; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 | 205 |
206 bool nextBool() { | 206 bool nextBool() { |
207 return _getBytes(1).isEven; | 207 return _getBytes(1).isEven; |
208 } | 208 } |
209 | 209 |
210 // Constants used by the algorithm. | 210 // Constants used by the algorithm. |
211 static const _POW2_32 = 1 << 32; | 211 static const _POW2_32 = 1 << 32; |
212 static const _POW2_53_D = 1.0 * (1 << 53); | 212 static const _POW2_53_D = 1.0 * (1 << 53); |
213 } | 213 } |
214 | 214 |
OLD | NEW |