Chromium Code Reviews| 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 // Dart core library. | 5 // Dart core library. |
| 6 | 6 |
| 7 abstract class num implements Comparable, Hashable { | 7 abstract class num implements Comparable, Hashable { |
| 8 // Arithmetic operations. | 8 /// Addition operator. |
|
Lasse Reichstein Nielsen
2012/09/20 12:49:38
Why the /// comments now? We don't do that anywher
Mads Ager (google)
2012/09/20 13:36:08
No particular reason. I think the comment style is
| |
| 9 num operator +(num other); | 9 num operator +(num other); |
|
Lasse Reichstein Nielsen
2012/09/20 12:49:38
empty line after declarations (except the last in
Mads Ager (google)
2012/09/20 13:36:08
Done.
| |
| 10 /// Subtraction operator. | |
| 10 num operator -(num other); | 11 num operator -(num other); |
| 12 /// Multiplication operator. | |
| 11 num operator *(num other); | 13 num operator *(num other); |
| 14 /// Euclidean modulo operator. | |
| 12 num operator %(num other); | 15 num operator %(num other); |
| 16 /// Division operator. | |
| 13 double operator /(num other); | 17 double operator /(num other); |
| 14 // Truncating division. | 18 /// Truncating division operator. |
| 19 /// | |
| 20 /// The result of the truncating division [:a ~/ b:] is equivalent to | |
| 21 /// [:(a / b).truncate():]. | |
| 15 num operator ~/(num other); | 22 num operator ~/(num other); |
| 16 // The unary '-' operator. | 23 /// Unary minus operator. |
|
Lasse Reichstein Nielsen
2012/09/20 12:49:38
That's the negate operator.
Mads Ager (google)
2012/09/20 13:36:08
Done.
| |
| 17 num operator -(); | 24 num operator -(); |
| 25 | |
| 26 /// Return the remainder from dividing this [num] by [other]. | |
| 18 num remainder(num other); | 27 num remainder(num other); |
| 19 | 28 |
| 20 // Relational operations. | 29 /// Relational less than operator. |
| 21 bool operator <(num other); | 30 bool operator <(num other); |
| 31 /// Relational less than or equal operator. | |
| 22 bool operator <=(num other); | 32 bool operator <=(num other); |
| 33 /// Relational greater than operator. | |
| 23 bool operator >(num other); | 34 bool operator >(num other); |
| 35 /// Relational greater than or equal operator. | |
| 24 bool operator >=(num other); | 36 bool operator >=(num other); |
| 25 | 37 |
| 26 // Predicates. | 38 /// isNan predicate. |
|
Lasse Reichstein Nielsen
2012/09/20 12:49:38
I'd rather be without this comment. It says nothin
Mads Ager (google)
2012/09/20 13:36:08
I have removed these comments. However, this poses
Lasse Reichstein Nielsen
2012/09/20 19:45:13
They increase the information (not by a lot, but s
| |
| 27 bool isNaN(); | 39 bool isNaN(); |
| 40 /// isNegative predicate. | |
| 28 bool isNegative(); | 41 bool isNegative(); |
| 42 /// isInfinite predicate. | |
| 29 bool isInfinite(); | 43 bool isInfinite(); |
| 30 | 44 |
| 45 /// Returns the absolute value of this [num]. | |
| 31 num abs(); | 46 num abs(); |
| 47 /// Returns the greatest integer value no greater than this [num]. | |
| 48 num floor(); | |
| 49 /// Returns the least integer value that is no smaller than this [num]. | |
| 50 num ceil(); | |
| 51 | |
| 52 /// Returns the integer value closest to this [num]. | |
| 53 /// | |
| 54 /// Rounds away from zero when there is no closest integer: | |
| 55 /// [:(3.5).round() == 4:] and [:(-3.5).round() == -4:]. | |
| 32 num round(); | 56 num round(); |
| 33 num floor(); | 57 |
| 34 num ceil(); | 58 /// Returns the integer value obtained by discarding any fractional |
| 59 /// digits from this [num]. | |
| 35 num truncate(); | 60 num truncate(); |
| 36 | 61 |
| 62 /// Truncates this [num] to an integer and returns the result as an [int]. | |
| 37 int toInt(); | 63 int toInt(); |
| 64 | |
| 65 /// Return this [num] as a [double]. | |
|
Lasse Reichstein Nielsen
2012/09/20 12:49:38
///
/// If the number is not representable as a [d
Mads Ager (google)
2012/09/20 13:36:08
Done, thanks.
| |
| 38 double toDouble(); | 66 double toDouble(); |
| 39 | 67 |
| 68 /// Converts a [num] to a string representation with [fractionDigits] | |
| 69 /// digits after the decimal point. | |
| 40 String toStringAsFixed(int fractionDigits); | 70 String toStringAsFixed(int fractionDigits); |
| 71 | |
| 72 /// Converts a [num] to a string in decimal exponential notation with | |
| 73 /// [fractionDigits] digits after the decimal point. | |
| 41 String toStringAsExponential(int fractionDigits); | 74 String toStringAsExponential(int fractionDigits); |
| 75 | |
| 76 /// Converts a [num] to a string representation with [precision] | |
| 77 /// significant digits. | |
| 42 String toStringAsPrecision(int precision); | 78 String toStringAsPrecision(int precision); |
| 43 | 79 |
| 44 /** | 80 /// Converts a [num] to a string representation in the given [radix]. |
| 45 * Converts a [num] to a string representation in the given [radix]. | 81 /// |
| 46 * | 82 /// The [num] in converted to an [int] using [toInt]. That [int] is |
| 47 * The [num] in converted to an [int] using [toInt]. That [int] is | 83 /// then converted to a string representation with the given |
| 48 * then converted to a string representation with the given | 84 /// [radix]. In the string representation, lower-case letters are |
| 49 * [radix]. In the string representation, lower-case letters are | 85 /// used for digits above '9'. |
| 50 * used for digits above '9'. | 86 /// |
| 51 * | 87 /// The [radix] argument must be an integer between 2 and 36. |
| 52 * The [radix] argument must be an integer between 2 and 36. | |
| 53 */ | |
| 54 String toRadixString(int radix); | 88 String toRadixString(int radix); |
| 55 } | 89 } |
| OLD | NEW |