Chromium Code Reviews| Index: lib/core/int.dart |
| diff --git a/lib/core/int.dart b/lib/core/int.dart |
| index 0855a62b6346bc89cb0e7dedec350eb5107e8f22..b103f402edcc824f6a099ef7212c4ec5375d75ba 100644 |
| --- a/lib/core/int.dart |
| +++ b/lib/core/int.dart |
| @@ -1,34 +1,68 @@ |
| -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| -// Dart core library. |
| - |
| +/** |
| + * Representation of Dart integers containing integer specific |
| + * operations and specialization of operations inherited from [num]. |
| + * |
| + * Integers are arbitrarily large in Dart. |
|
Lasse Reichstein Nielsen
2012/09/24 11:54:12
are -> can be
Mads Ager (google)
2012/09/24 12:26:27
Done.
|
| + * |
| + * *Note however, that when compiling to JavaScript, integers are |
| + * implemented as JavaScript numbers. When compiling to JavaScript, |
| + * integers are therefore restricted to 53 bits because all JavaScript |
|
Lasse Reichstein Nielsen
2012/09/24 11:54:12
53 bits -> 53 significant bits
Mads Ager (google)
2012/09/24 12:26:27
Done.
|
| + * numbers are double-precision floating point values. The behavior of |
| + * the operators and methods in the [int] class therefore sometimes |
| + * differs between the Dart VM and Dart code compiled to JavaScript.* |
| + */ |
| abstract class int implements num { |
| - // Bit-operations. |
| + /** The bit-wise and operator. */ |
| int operator &(int other); |
| + |
| + /** The bit-wise or operator. */ |
| int operator |(int other); |
| + |
| + /** The bit-wise xor operator. */ |
| int operator ^(int other); |
| + |
| + /** The bit-wise negate operator. */ |
| int operator ~(); |
| + |
| + /** The left shift operator. */ |
| int operator <<(int shiftAmount); |
| + |
| + /** The right shift operator. */ |
| int operator >>(int shiftAmount); |
| - // Testers. |
| + /** Returns true if and only if this integer is even. */ |
| bool isEven(); |
| + |
| + /** Returns true if and only if this integer is odd. */ |
| bool isOdd(); |
| - // Specializations of super-interface. |
| + /** Negate operator. Negating an integer produces an integer. */ |
| int operator -(); |
| + |
| + /** Returns the absolute value of this integer. */ |
| int abs(); |
| + |
| + /** For integers the round method is the identify function. */ |
| int round(); |
| + |
| + /** For integers the floor method is the identify function. */ |
| int floor(); |
| + |
| + /** For integers the ceil method is the identify function. */ |
| int ceil(); |
| + |
| + /** For integers the ceil method is the identify function. */ |
|
Lasse Reichstein Nielsen
2012/09/24 11:54:12
ceil -> truncate.
Mads Ager (google)
2012/09/24 12:26:27
Good catch. Thanks!
|
| int truncate(); |
| + |
| /** |
| * Returns a representation of this [int] value. |
| * |
| - * It should always be the case that if 'i' is an [int] value, then |
| - * [:i == int.parse(i.toString())]. |
| + * It should always be the case that if [:i:] is an [int] value, |
| + * then [:i == int.parse(i.toString()):]. |
| */ |
| String toString(); |
| @@ -37,6 +71,7 @@ abstract class int implements num { |
| * |
| * Accepts "0x" prefix for hexadecimal numbers, otherwise defaults |
| * to base-10. |
| + * |
| * Throws a [FormatException] if [source] is not a valid integer literal. |
| */ |
| external static int parse(String source); |