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

Side by Side Diff: pkg/dev_compiler/tool/input_sdk/lib/math/math.dart

Issue 2698353003: unfork DDC's copy of most SDK libraries (Closed)
Patch Set: revert core_patch Created 3 years, 9 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * Mathematical constants and functions, plus a random number generator.
7 *
8 * To use this library in your code:
9 *
10 * import 'dart:math';
11 */
12 library dart.math;
13
14 part "jenkins_smi_hash.dart";
15 part "point.dart";
16 part "random.dart";
17 part "rectangle.dart";
18
19 /**
20 * Base of the natural logarithms.
21 *
22 * Typically written as "e".
23 */
24 const double E = 2.718281828459045;
25
26 /**
27 * Natural logarithm of 10.
28 */
29 const double LN10 = 2.302585092994046;
30
31 /**
32 * Natural logarithm of 2.
33 */
34 const double LN2 = 0.6931471805599453;
35
36 /**
37 * Base-2 logarithm of [E].
38 */
39 const double LOG2E = 1.4426950408889634;
40
41 /**
42 * Base-10 logarithm of [E].
43 */
44 const double LOG10E = 0.4342944819032518;
45
46 /**
47 * The PI constant.
48 */
49 const double PI = 3.1415926535897932;
50
51 /**
52 * Square root of 1/2.
53 */
54 const double SQRT1_2 = 0.7071067811865476;
55
56 /**
57 * Square root of 2.
58 */
59 const double SQRT2 = 1.4142135623730951;
60
61 /**
62 * Returns the lesser of two numbers.
63 *
64 * Returns NaN if either argument is NaN.
65 * The lesser of `-0.0` and `0.0` is `-0.0`.
66 * If the arguments are otherwise equal (including int and doubles with the
67 * same mathematical value) then it is unspecified which of the two arguments
68 * is returned.
69 */
70 external num/*=T*/ min/*<T extends num>*/(num/*=T*/ a, num/*=T*/ b);
71
72 /**
73 * Returns the larger of two numbers.
74 *
75 * Returns NaN if either argument is NaN.
76 * The larger of `-0.0` and `0.0` is `0.0`. If the arguments are
77 * otherwise equal (including int and doubles with the same mathematical value)
78 * then it is unspecified which of the two arguments is returned.
79 */
80 external num/*=T*/ max/*<T extends num>*/(num/*=T*/ a, num/*=T*/ b);
81
82 /**
83 * A variant of [atan].
84 *
85 * Converts both arguments to doubles.
86 *
87 * Returns the angle between the positive x-axis and the vector ([b],[a]).
88 * The result, in radians, is in the range -PI..PI.
89 *
90 * If [b] is positive, this is the same as `atan(b/a)`.
91 *
92 * The result is negative when [a] is negative (including when [a] is the
93 * double -0.0).
94 *
95 * If [a] is equal to zero, the vector ([b],[a]) is considered parallel to
96 * the x-axis, even if [b] is also equal to zero. The sign of [b] determines
97 * the direction of the vector along the x-axis.
98 *
99 * Returns NaN if either argument is NaN.
100 */
101 external double atan2(num a, num b);
102
103 /**
104 * Returns [x] to the power of [exponent].
105 *
106 * If [x] is an [int] and [exponent] is a non-negative [int], the result is
107 * an [int], otherwise both arguments are converted to doubles first, and the
108 * result is a [double].
109 *
110 * For integers, the power is always equal to the mathematical result of `x` to
111 * the power `exponent`, only limited by the available memory.
112 *
113 * For doubles, `pow(x, y)` handles edge cases as follows:
114 *
115 * - if `y` is zero (0.0 or -0.0), the result is always 1.0.
116 * - if `x` is 1.0, the result is always 1.0.
117 * - otherwise, if either `x` or `y` is NaN then the result is NaN.
118 * - if `x` is negative (but not -0.0) and `y` is a finite non-integer, the
119 * result is NaN.
120 * - if `x` is Infinity and `y` is negative, the result is 0.0.
121 * - if `x` is Infinity and `y` is positive, the result is Infinity.
122 * - if `x` is 0.0 and `y` is negative, the result is Infinity.
123 * - if `x` is 0.0 and `y` is positive, the result is 0.0.
124 * - if `x` is -Infinity or -0.0 and `y` is an odd integer, then the result is
125 * `-pow(-x ,y)`.
126 * - if `x` is -Infinity or -0.0 and `y` is not an odd integer, then the result
127 * is the same as `pow(-x , y)`.
128 * - if `y` is Infinity and the absolute value of `x` is less than 1, the
129 * result is 0.0.
130 * - if `y` is Infinity and `x` is -1, the result is 1.0.
131 * - if `y` is Infinity and the absolute value of `x` is greater than 1,
132 * the result is Infinity.
133 * - if `y` is -Infinity, the result is `1/pow(x, Infinity)`.
134 *
135 * This corresponds to the `pow` function defined in the IEEE Standard 754-2008.
136 *
137 * Notice that an [int] result cannot overflow, but a [double] result might
138 * be [double.INFINITY].
139 */
140 external num pow(num x, num exponent);
141
142 /**
143 * Converts [x] to a double and returns the sine of the value.
144 *
145 * If [x] is not a finite number, the result is NaN.
146 */
147 external double sin(num x);
148
149 /**
150 * Converts [x] to a double and returns the cosine of the value.
151 *
152 * If [x] is not a finite number, the result is NaN.
153 */
154 external double cos(num x);
155
156 /**
157 * Converts [x] to a double and returns the tangent of the value.
158 *
159 * The tangent function is equivalent to `sin(x)/cos(x)` and may be
160 * infinite (positive or negative) when `cos(x)` is equal to zero.
161 * If [x] is not a finite number, the result is NaN.
162 */
163 external double tan(num x);
164
165 /**
166 * Converts [x] to a double and returns the arc cosine of the value.
167 *
168 * Returns a value in the range 0..PI, or NaN if [x] is outside
169 * the range -1..1.
170 */
171 external double acos(num x);
172
173 /**
174 * Converts [x] to a double and returns the arc sine of the value.
175 *
176 * Returns a value in the range -PI/2..PI/2, or NaN if [x] is outside
177 * the range -1..1.
178 */
179 external double asin(num x);
180
181 /**
182 * Converts [x] to a double and returns the arc tangent of the value.
183 *
184 * Returns a value in the range -PI/2..PI/2, or NaN if [x] is NaN.
185 */
186 external double atan(num x);
187
188 /**
189 * Converts [x] to a double and returns the positive square root of the value.
190 *
191 * Returns -0.0 if [x] is -0.0, and NaN if [x] is otherwise negative or NaN.
192 */
193 external double sqrt(num x);
194
195 /**
196 * Converts [x] to a double and returns the natural exponent, [E],
197 * to the power [x].
198 *
199 * Returns NaN if [x] is NaN.
200 */
201 external double exp(num x);
202
203 /**
204 * Converts [x] to a double and returns the natural logarithm of the value.
205 *
206 * Returns negative infinity if [x] is equal to zero.
207 * Returns NaN if [x] is NaN or less than zero.
208 */
209 external double log(num x);
OLDNEW
« no previous file with comments | « pkg/dev_compiler/tool/input_sdk/lib/math/jenkins_smi_hash.dart ('k') | pkg/dev_compiler/tool/input_sdk/lib/math/point.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698