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

Side by Side Diff: lib/core/num.dart

Issue 10961013: Add minimal documentation to the num class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 3 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 | « no previous file | 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 // 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. */
9 num operator +(num other); 9 num operator +(num other);
10
11 /** Subtraction operator. */
10 num operator -(num other); 12 num operator -(num other);
13
14 /** Multiplication operator. */
11 num operator *(num other); 15 num operator *(num other);
16
17 /** Euclidean modulo operator. */
12 num operator %(num other); 18 num operator %(num other);
19
20 /** Division operator. */
13 double operator /(num other); 21 double operator /(num other);
14 // Truncating division. 22
23 /**
24 * Truncating division operator.
25 *
26 * The result of the truncating division [:a ~/ b:] is equivalent to
27 * [:(a / b).truncate():].
28 */
15 num operator ~/(num other); 29 num operator ~/(num other);
16 // The unary '-' operator. 30
31 /** Negate operator. */
17 num operator -(); 32 num operator -();
33
34 /** Return the remainder from dividing this [num] by [other]. */
18 num remainder(num other); 35 num remainder(num other);
19 36
20 // Relational operations. 37 /** Relational less than operator. */
21 bool operator <(num other); 38 bool operator <(num other);
39
40 /** Relational less than or equal operator. */
22 bool operator <=(num other); 41 bool operator <=(num other);
42
43 /** Relational greater than operator. */
23 bool operator >(num other); 44 bool operator >(num other);
45
46 /** Relational greater than or equal operator. */
24 bool operator >=(num other); 47 bool operator >=(num other);
25 48
26 // Predicates.
27 bool isNaN(); 49 bool isNaN();
50
28 bool isNegative(); 51 bool isNegative();
52
29 bool isInfinite(); 53 bool isInfinite();
30 54
55 /** Returns the absolute value of this [num]. */
31 num abs(); 56 num abs();
57
58 /** Returns the greatest integer value no greater than this [num]. */
59 num floor();
60
61 /** Returns the least integer value that is no smaller than this [num]. */
62 num ceil();
63
64 /**
65 * Returns the integer value closest to this [num].
66 *
67 * Rounds away from zero when there is no closest integer:
68 * [:(3.5).round() == 4:] and [:(-3.5).round() == -4:].
69 */
32 num round(); 70 num round();
33 num floor(); 71
34 num ceil(); 72 /**
73 * Returns the integer value obtained by discarding any fractional
74 * digits from this [num].
75 */
35 num truncate(); 76 num truncate();
36 77
78 /** Truncates this [num] to an integer and returns the result as an [int]. */
37 int toInt(); 79 int toInt();
80
81 /**
82 * Return this [num] as a [double].
83 *
84 * If the number is not representable as a [double], an
85 * approximation is returned. For numerically large integers, the
86 * approximation may be infinite.
87 */
38 double toDouble(); 88 double toDouble();
39 89
90 /**
91 * Converts a [num] to a string representation with [fractionDigits]
92 * digits after the decimal point.
93 */
40 String toStringAsFixed(int fractionDigits); 94 String toStringAsFixed(int fractionDigits);
95
96 /**
97 * Converts a [num] to a string in decimal exponential notation with
98 * [fractionDigits] digits after the decimal point.
99 */
41 String toStringAsExponential(int fractionDigits); 100 String toStringAsExponential(int fractionDigits);
101
102 /**
103 * Converts a [num] to a string representation with [precision]
104 * significant digits.
105 */
42 String toStringAsPrecision(int precision); 106 String toStringAsPrecision(int precision);
43 107
44 /** 108 /**
45 * Converts a [num] to a string representation in the given [radix]. 109 * Converts a [num] to a string representation in the given [radix].
46 * 110 *
47 * The [num] in converted to an [int] using [toInt]. That [int] is 111 * The [num] in converted to an [int] using [toInt]. That [int] is
48 * then converted to a string representation with the given 112 * then converted to a string representation with the given
49 * [radix]. In the string representation, lower-case letters are 113 * [radix]. In the string representation, lower-case letters are
50 * used for digits above '9'. 114 * used for digits above '9'.
51 * 115 *
52 * The [radix] argument must be an integer between 2 and 36. 116 * The [radix] argument must be an integer between 2 and 36.
53 */ 117 */
54 String toRadixString(int radix); 118 String toRadixString(int radix);
55 } 119 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698