OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Dart core library. | 5 // Dart core library. |
6 | 6 |
7 class Math { | 7 class Math { |
8 /** | 8 /** |
9 * Base of the natural logarithms. | 9 * Base of the natural logarithms. |
10 */ | 10 */ |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // [min] must also distinguish between -0.0 and 0.0. | 77 // [min] must also distinguish between -0.0 and 0.0. |
78 if (a is double) { | 78 if (a is double) { |
79 if (a == 0.0) { | 79 if (a == 0.0) { |
80 // a is either 0.0 or -0.0. b is either 0.0, -0.0 or NaN. | 80 // a is either 0.0 or -0.0. b is either 0.0, -0.0 or NaN. |
81 // The following returns -0.0 if either a or b is -0.0, and it | 81 // The following returns -0.0 if either a or b is -0.0, and it |
82 // returns NaN if b is NaN. | 82 // returns NaN if b is NaN. |
83 return (a + b) * a * b; | 83 return (a + b) * a * b; |
84 } | 84 } |
85 } | 85 } |
86 // Check for NaN and b == -0.0. | 86 // Check for NaN and b == -0.0. |
87 if (a == 0 && b.isNegative() || b.isNan()) return b; | 87 if (a == 0 && b.isNegative() || b.isNaN()) return b; |
88 return a; | 88 return a; |
89 } | 89 } |
90 return a; | 90 return a; |
91 } | 91 } |
92 throw new IllegalArgumentException(b); | 92 throw new IllegalArgumentException(b); |
93 } | 93 } |
94 throw new IllegalArgumentException(a); | 94 throw new IllegalArgumentException(a); |
95 } | 95 } |
96 | 96 |
97 /** | 97 /** |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 static double sin(num x) => MathNatives.sin(x); | 151 static double sin(num x) => MathNatives.sin(x); |
152 static double cos(num x) => MathNatives.cos(x); | 152 static double cos(num x) => MathNatives.cos(x); |
153 static double tan(num x) => MathNatives.tan(x); | 153 static double tan(num x) => MathNatives.tan(x); |
154 static double acos(num x) => MathNatives.acos(x); | 154 static double acos(num x) => MathNatives.acos(x); |
155 static double asin(num x) => MathNatives.asin(x); | 155 static double asin(num x) => MathNatives.asin(x); |
156 static double atan(num x) => MathNatives.atan(x); | 156 static double atan(num x) => MathNatives.atan(x); |
157 static double sqrt(num x) => MathNatives.sqrt(x); | 157 static double sqrt(num x) => MathNatives.sqrt(x); |
158 static double exp(num x) => MathNatives.exp(x); | 158 static double exp(num x) => MathNatives.exp(x); |
159 static double log(num x) => MathNatives.log(x); | 159 static double log(num x) => MathNatives.log(x); |
160 } | 160 } |
OLD | NEW |