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 part of dart.core; | 5 part of dart.core; |
6 | 6 |
7 /** | 7 /** |
8 * An integer or floating-point number. | 8 * An integer or floating-point number. |
9 * | 9 * |
10 * It is a compile-time error for any type other than [int] or [double] | 10 * It is a compile-time error for any type other than [int] or [double] |
(...skipping 24 matching lines...) Expand all Loading... |
35 * otherwise required of `operator==`. Using NaN in, e.g., a [HashSet] | 35 * otherwise required of `operator==`. Using NaN in, e.g., a [HashSet] |
36 * will fail to work. The behavior is the standard IEEE-754 equality of | 36 * will fail to work. The behavior is the standard IEEE-754 equality of |
37 * doubles. | 37 * doubles. |
38 * | 38 * |
39 * If you can avoid NaN values, the remaining doubles do have a proper | 39 * If you can avoid NaN values, the remaining doubles do have a proper |
40 * equality relation, and can be used safely. | 40 * equality relation, and can be used safely. |
41 * | 41 * |
42 * Use [compareTo] for a comparison that distinguishes zero and minus zero, | 42 * Use [compareTo] for a comparison that distinguishes zero and minus zero, |
43 * and that considers NaN values as equal. | 43 * and that considers NaN values as equal. |
44 */ | 44 */ |
45 bool operator==(Object other); | 45 bool operator ==(Object other); |
46 | 46 |
47 /** | 47 /** |
48 * Returns a hash code for a numerical value. | 48 * Returns a hash code for a numerical value. |
49 * | 49 * |
50 * The hash code is compatible with equality. It returns the same value | 50 * The hash code is compatible with equality. It returns the same value |
51 * for an [int] and a [double] with the same numerical value, and therefore | 51 * for an [int] and a [double] with the same numerical value, and therefore |
52 * the same value for the doubles zero and minus zero. | 52 * the same value for the doubles zero and minus zero. |
53 * | 53 * |
54 * No guarantees are made about the hash code of NaN values. | 54 * No guarantees are made about the hash code of NaN values. |
55 */ | 55 */ |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 * `a ~/ b` is equivalent to `(a / b).truncate().toInt()`. | 139 * `a ~/ b` is equivalent to `(a / b).truncate().toInt()`. |
140 * | 140 * |
141 * If both operands are [int]s then `a ~/ b` performs the truncating | 141 * If both operands are [int]s then `a ~/ b` performs the truncating |
142 * integer division. | 142 * integer division. |
143 */ | 143 */ |
144 int operator ~/(num other); | 144 int operator ~/(num other); |
145 | 145 |
146 /** Negate operator. */ | 146 /** Negate operator. */ |
147 num operator -(); | 147 num operator -(); |
148 | 148 |
149 /** | 149 /** |
150 * Returns the remainder of the truncating division of `this` by [other]. | 150 * Returns the remainder of the truncating division of `this` by [other]. |
151 * | 151 * |
152 * The result `r` of this operation satisfies: | 152 * The result `r` of this operation satisfies: |
153 * `this == (this ~/ other) * other + r`. | 153 * `this == (this ~/ other) * other + r`. |
154 * As a consequence the remainder `r` has the same sign as the divider `this`. | 154 * As a consequence the remainder `r` has the same sign as the divider `this`. |
155 */ | 155 */ |
156 num remainder(num other); | 156 num remainder(num other); |
157 | 157 |
158 /** Relational less than operator. */ | 158 /** Relational less than operator. */ |
159 bool operator <(num other); | 159 bool operator <(num other); |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 result = double.parse(source, _returnDoubleNull); | 471 result = double.parse(source, _returnDoubleNull); |
472 if (result != null) return result; | 472 if (result != null) return result; |
473 if (onError == null) throw new FormatException(input); | 473 if (onError == null) throw new FormatException(input); |
474 return onError(input); | 474 return onError(input); |
475 } | 475 } |
476 | 476 |
477 /** Helper functions for [parse]. */ | 477 /** Helper functions for [parse]. */ |
478 static int _returnIntNull(String _) => null; | 478 static int _returnIntNull(String _) => null; |
479 static double _returnDoubleNull(String _) => null; | 479 static double _returnDoubleNull(String _) => null; |
480 } | 480 } |
OLD | NEW |