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

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

Issue 1462743002: add generic method comments to a few SDK methods (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
« sdk/lib/async/future.dart ('K') | « sdk/lib/core/iterable.dart ('k') | no next file » | 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 "jenkins_smi_hash.dart"; 10 part "jenkins_smi_hash.dart";
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 /** 57 /**
58 * Returns the lesser of two numbers. 58 * Returns the lesser of two numbers.
59 * 59 *
60 * Returns NaN if either argument is NaN. 60 * Returns NaN if either argument is NaN.
61 * The lesser of [:-0.0:] and [:0.0:] is [:-0.0:]. 61 * The lesser of [:-0.0:] and [:0.0:] is [:-0.0:].
62 * If the arguments are otherwise equal (including int and doubles with the 62 * If the arguments are otherwise equal (including int and doubles with the
63 * same mathematical value) then it is unspecified which of the two arguments 63 * same mathematical value) then it is unspecified which of the two arguments
64 * is returned. 64 * is returned.
65 */ 65 */
66 num min(num a, num b) { 66 num/*=T*/ max/*<T extends num>*/(num/*=T*/ a, num/*=T*/ b) {
Lasse Reichstein Nielsen 2015/11/19 06:58:32 Is this a way to say that max of two doubles is a
Jennifer Messerly 2015/11/20 17:41:18 Exactly.
67 // These partially redundant type checks improve code quality for dart2js. 67 // These partially redundant type checks improve code quality for dart2js.
68 // Most of the improvement is at call sites from the inferred non-null num 68 // Most of the improvement is at call sites from the inferred non-null num
69 // return type. 69 // return type.
70 if (a is! num) throw new ArgumentError(a); 70 if (a is! num) throw new ArgumentError(a);
71 if (b is! num) throw new ArgumentError(b); 71 if (b is! num) throw new ArgumentError(b);
72 72
73 if (a > b) return b; 73 if (a > b) return b;
74 if (a < b) return a; 74 if (a < b) return a;
75 if (b is double) { 75 if (b is double) {
76 // Special case for NaN and -0.0. If one argument is NaN return NaN. 76 // Special case for NaN and -0.0. If one argument is NaN return NaN.
(...skipping 14 matching lines...) Expand all
91 } 91 }
92 92
93 /** 93 /**
94 * Returns the larger of two numbers. 94 * Returns the larger of two numbers.
95 * 95 *
96 * Returns NaN if either argument is NaN. 96 * Returns NaN if either argument is NaN.
97 * The larger of [:-0.0:] and [:0.0:] is [:0.0:]. If the arguments are 97 * The larger of [:-0.0:] and [:0.0:] is [:0.0:]. If the arguments are
98 * otherwise equal (including int and doubles with the same mathematical value) 98 * otherwise equal (including int and doubles with the same mathematical value)
99 * then it is unspecified which of the two arguments is returned. 99 * then it is unspecified which of the two arguments is returned.
100 */ 100 */
101 num max(num a, num b) { 101 num/*=T*/ max/*<T extends num>*/(num/*=T*/ a, num/*=T*/ b) {
102 // These partially redundant type checks improve code quality for dart2js. 102 // These partially redundant type checks improve code quality for dart2js.
103 // Most of the improvement is at call sites from the inferred non-null num 103 // Most of the improvement is at call sites from the inferred non-null num
104 // return type. 104 // return type.
105 if (a is! num) throw new ArgumentError(a); 105 if (a is! num) throw new ArgumentError(a);
106 if (b is! num) throw new ArgumentError(b); 106 if (b is! num) throw new ArgumentError(b);
107 107
108 if (a > b) return a; 108 if (a > b) return a;
109 if (a < b) return b; 109 if (a < b) return b;
110 if (b is double) { 110 if (b is double) {
111 // Special case for NaN and -0.0. If one argument is NaN return NaN. 111 // 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
248 */ 248 */
249 external double exp(num x); 249 external double exp(num x);
250 250
251 /** 251 /**
252 * Converts [x] to a double and returns the natural logarithm of the value. 252 * Converts [x] to a double and returns the natural logarithm of the value.
253 * 253 *
254 * Returns negative infinity if [x] is equal to zero. 254 * Returns negative infinity if [x] is equal to zero.
255 * Returns NaN if [x] is NaN or less than zero. 255 * Returns NaN if [x] is NaN or less than zero.
256 */ 256 */
257 external double log(num x); 257 external double log(num x);
OLDNEW
« sdk/lib/async/future.dart ('K') | « sdk/lib/core/iterable.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698