Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: sdk/lib/math/math.dart

Issue 22943005: Add documentation to dart:math pow function. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/lib/math_patch.dart ('k') | tests/co19/co19-runtime.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /** 5 /**
6 * Mathematical constants and functions, plus a random number generator. 6 * Mathematical constants and functions, plus a random number generator.
7 */ 7 */
8 library dart.math; 8 library dart.math;
9 9
10 part "random.dart"; 10 part "random.dart";
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 * the direction of the vector along the x-axis. 130 * the direction of the vector along the x-axis.
131 * 131 *
132 * Returns NaN if either argument is NaN. 132 * Returns NaN if either argument is NaN.
133 */ 133 */
134 external double atan2(num a, num b); 134 external double atan2(num a, num b);
135 135
136 /** 136 /**
137 * Returns [x] to the power of [exponent]. 137 * Returns [x] to the power of [exponent].
138 * 138 *
139 * If [x] is an [int] and [exponent] is a non-negative [int], the result is 139 * If [x] is an [int] and [exponent] is a non-negative [int], the result is
140 * an [int], otherwise the result it is a [double]. 140 * an [int], otherwise both arguments are converted to doubles first, and the
141 * result is a [double].
142 *
143 * For integers, the power is always equal to the mathematical result of `x` to
144 * the power `exponent`, only limited by the available memory.
145 *
146 * For doubles, `pow(x, y)` handles edge cases as follows:
147 *
148 * - if `y` is zero (0.0 or -0.0), the result is always 1.0.
149 * - if `x` is 1.0, the result is always 1.0.
150 * - otherwise, if either `x` or `y` is NaN then the result is NaN.
151 * - if `x` is negative (but not -0.0) and `y` is a finite non-integer, the
152 * result is NaN.
153 * - if `x` is Infinity and `y` is negative, the result is 0.0.
154 * - if `x` is Infinity and `y` is positive, the result is Infinity.
155 * - if `x` is 0.0 and `y` is negative, the result is Infinity.
156 * - if `x` is 0.0 and `y` is positive, the result is 0.0.
157 * - if `x` is -Infinity or -0.0 and `y` is an odd integer, then the result is
158 * `-pow(-x ,y)`.
159 * - if `x` is -Infinity or -0.0 and `y` is not an odd integer, then the result
160 * is the same as `pow(-x , y)`.
161 * - if `y` is Infinity and the absolute value of `x` is less than 1, the
162 * result is 0.0.
163 * - if `y` is Infinity and `x` is -1, the result is 1.0.
164 * - if `y` is Infinity and the absolute value of `x` is greater than 1,
165 * the result is Infinity.
166 * - if `y` is -Infinity, the result is `1/pow(x, Infinity)`.
167 *
168 * This corresponds to the `pow` function defined in the IEEE Standard 754-2008.
141 * 169 *
142 * Notice that an [int] result cannot overflow, but a [double] result might 170 * Notice that an [int] result cannot overflow, but a [double] result might
143 * be [double.INFINITY]. 171 * be [double.INFINITY].
144 */ 172 */
145 external num pow(num x, num exponent); 173 external num pow(num x, num exponent);
146 174
147 /** 175 /**
148 * Converts [x] to a double and returns the sine of the value. 176 * Converts [x] to a double and returns the sine of the value.
149 * 177 *
150 * If [x] is not a finite number, the result is NaN. 178 * If [x] is not a finite number, the result is NaN.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 * Returns NaN if [x] is NaN. 229 * Returns NaN if [x] is NaN.
202 */ 230 */
203 external double exp(num x); 231 external double exp(num x);
204 232
205 /** 233 /**
206 * Converts [x] to a double and returns the natural logarithm of the value. 234 * Converts [x] to a double and returns the natural logarithm of the value.
207 * Returns negative infinity if [x] is equal to zero. 235 * Returns negative infinity if [x] is equal to zero.
208 * Returns NaN if [x] is NaN or less than zero. 236 * Returns NaN if [x] is NaN or less than zero.
209 */ 237 */
210 external double log(num x); 238 external double log(num x);
OLDNEW
« no previous file with comments | « runtime/lib/math_patch.dart ('k') | tests/co19/co19-runtime.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698