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

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

Issue 2529393002: Make core libraries use generic method syntax. (Closed)
Patch Set: Merge to head Created 4 years 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
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 * To use this library in your code: 8 * To use this library in your code:
9 * 9 *
10 * import 'dart:math'; 10 * import 'dart:math';
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 /** 61 /**
62 * Returns the lesser of two numbers. 62 * Returns the lesser of two numbers.
63 * 63 *
64 * Returns NaN if either argument is NaN. 64 * Returns NaN if either argument is NaN.
65 * The lesser of `-0.0` and `0.0` is `-0.0`. 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 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 67 * same mathematical value) then it is unspecified which of the two arguments
68 * is returned. 68 * is returned.
69 */ 69 */
70 num/*=T*/ min/*<T extends num>*/(num/*=T*/ a, num/*=T*/ b) { 70 T min<T extends num>(T a, T b) {
71 // These partially redundant type checks improve code quality for dart2js. 71 // These partially redundant type checks improve code quality for dart2js.
72 // Most of the improvement is at call sites from the inferred non-null num 72 // Most of the improvement is at call sites from the inferred non-null num
73 // return type. 73 // return type.
74 if (a is! num) throw new ArgumentError(a); 74 if (a is! num) throw new ArgumentError(a);
75 if (b is! num) throw new ArgumentError(b); 75 if (b is! num) throw new ArgumentError(b);
76 76
77 if (a > b) return b; 77 if (a > b) return b;
78 if (a < b) return a; 78 if (a < b) return a;
79 if (b is double) { 79 if (b is double) {
80 // Special case for NaN and -0.0. If one argument is NaN return NaN. 80 // Special case for NaN and -0.0. If one argument is NaN return NaN.
(...skipping 14 matching lines...) Expand all
95 } 95 }
96 96
97 /** 97 /**
98 * Returns the larger of two numbers. 98 * Returns the larger of two numbers.
99 * 99 *
100 * Returns NaN if either argument is NaN. 100 * Returns NaN if either argument is NaN.
101 * The larger of `-0.0` and `0.0` is `0.0`. If the arguments are 101 * The larger of `-0.0` and `0.0` is `0.0`. If the arguments are
102 * otherwise equal (including int and doubles with the same mathematical value) 102 * otherwise equal (including int and doubles with the same mathematical value)
103 * then it is unspecified which of the two arguments is returned. 103 * then it is unspecified which of the two arguments is returned.
104 */ 104 */
105 num/*=T*/ max/*<T extends num>*/(num/*=T*/ a, num/*=T*/ b) { 105 T max<T extends num>(T a, T b) {
106 // These partially redundant type checks improve code quality for dart2js. 106 // These partially redundant type checks improve code quality for dart2js.
107 // Most of the improvement is at call sites from the inferred non-null num 107 // Most of the improvement is at call sites from the inferred non-null num
108 // return type. 108 // return type.
109 if (a is! num) throw new ArgumentError(a); 109 if (a is! num) throw new ArgumentError(a);
110 if (b is! num) throw new ArgumentError(b); 110 if (b is! num) throw new ArgumentError(b);
111 111
112 if (a > b) return a; 112 if (a > b) return a;
113 if (a < b) return b; 113 if (a < b) return b;
114 if (b is double) { 114 if (b is double) {
115 // Special case for NaN and -0.0. If one argument is NaN return NaN. 115 // Special case for NaN and -0.0. If one argument is NaN return NaN.
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 */ 252 */
253 external double exp(num x); 253 external double exp(num x);
254 254
255 /** 255 /**
256 * Converts [x] to a double and returns the natural logarithm of the value. 256 * Converts [x] to a double and returns the natural logarithm of the value.
257 * 257 *
258 * Returns negative infinity if [x] is equal to zero. 258 * Returns negative infinity if [x] is equal to zero.
259 * Returns NaN if [x] is NaN or less than zero. 259 * Returns NaN if [x] is NaN or less than zero.
260 */ 260 */
261 external double log(num x); 261 external double log(num x);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698