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 * Base of the natural logarithms. | 8 * Base of the natural logarithms. |
9 * | 9 * |
10 * Typically written as "e". | 10 * Typically written as "e". |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // [min] must also distinguish between -0.0 and 0.0. | 73 // [min] must also distinguish between -0.0 and 0.0. |
74 if (a is double) { | 74 if (a is double) { |
75 if (a == 0.0) { | 75 if (a == 0.0) { |
76 // a is either 0.0 or -0.0. b is either 0.0, -0.0 or NaN. | 76 // a is either 0.0 or -0.0. b is either 0.0, -0.0 or NaN. |
77 // The following returns -0.0 if either a or b is -0.0, and it | 77 // The following returns -0.0 if either a or b is -0.0, and it |
78 // returns NaN if b is NaN. | 78 // returns NaN if b is NaN. |
79 return (a + b) * a * b; | 79 return (a + b) * a * b; |
80 } | 80 } |
81 } | 81 } |
82 // Check for NaN and b == -0.0. | 82 // Check for NaN and b == -0.0. |
83 if (a == 0 && b.isNegative() || b.isNaN()) return b; | 83 if (a == 0 && b.isNegative || b.isNaN) return b; |
84 return a; | 84 return a; |
85 } | 85 } |
86 return a; | 86 return a; |
87 } | 87 } |
88 throw new ArgumentError(b); | 88 throw new ArgumentError(b); |
89 } | 89 } |
90 throw new ArgumentError(a); | 90 throw new ArgumentError(a); |
91 } | 91 } |
92 | 92 |
93 /** | 93 /** |
(...skipping 16 matching lines...) Expand all Loading... |
110 // [max] must also distinguish between -0.0 and 0.0. | 110 // [max] must also distinguish between -0.0 and 0.0. |
111 if (a is double) { | 111 if (a is double) { |
112 if (a == 0.0) { | 112 if (a == 0.0) { |
113 // a is either 0.0 or -0.0. b is either 0.0, -0.0, or NaN. | 113 // a is either 0.0 or -0.0. b is either 0.0, -0.0, or NaN. |
114 // The following returns 0.0 if either a or b is 0.0, and it | 114 // The following returns 0.0 if either a or b is 0.0, and it |
115 // returns NaN if b is NaN. | 115 // returns NaN if b is NaN. |
116 return a + b; | 116 return a + b; |
117 } | 117 } |
118 } | 118 } |
119 // Check for NaN. | 119 // Check for NaN. |
120 if (b.isNaN()) return b; | 120 if (b.isNaN) return b; |
121 return a; | 121 return a; |
122 } | 122 } |
123 // max(-0.0, 0) must return 0. | 123 // max(-0.0, 0) must return 0. |
124 if (b == 0 && a.isNegative()) return b; | 124 if (b == 0 && a.isNegative) return b; |
125 return a; | 125 return a; |
126 } | 126 } |
127 throw new ArgumentError(b); | 127 throw new ArgumentError(b); |
128 } | 128 } |
129 throw new ArgumentError(a); | 129 throw new ArgumentError(a); |
130 } | 130 } |
131 | 131 |
132 /** | 132 /** |
133 * A variant of [atan]. | 133 * A variant of [atan]. |
134 * | 134 * |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 * Returns NaN if [x] is NaN. | 218 * Returns NaN if [x] is NaN. |
219 */ | 219 */ |
220 external double exp(num x); | 220 external double exp(num x); |
221 | 221 |
222 /** | 222 /** |
223 * Converts [x] to a double and returns the natural logarithm of the value. | 223 * Converts [x] to a double and returns the natural logarithm of the value. |
224 * Returns negative infinity if [x] is equal to zero. | 224 * Returns negative infinity if [x] is equal to zero. |
225 * Returns NaN if [x] is NaN or less than zero. | 225 * Returns NaN if [x] is NaN or less than zero. |
226 */ | 226 */ |
227 external double log(num x); | 227 external double log(num x); |
OLD | NEW |