Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, 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 /** |
| 6 * Representation of Dart integers containing integer specific | |
| 7 * operations and specialization of operations inherited from [num]. | |
| 8 * | |
| 9 * 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.
| |
| 10 * | |
| 11 * *Note however, that when compiling to JavaScript, integers are | |
| 12 * implemented as JavaScript numbers. When compiling to JavaScript, | |
| 13 * 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.
| |
| 14 * numbers are double-precision floating point values. The behavior of | |
| 15 * the operators and methods in the [int] class therefore sometimes | |
| 16 * differs between the Dart VM and Dart code compiled to JavaScript.* | |
| 17 */ | |
| 18 abstract class int implements num { | |
| 19 /** The bit-wise and operator. */ | |
| 20 int operator &(int other); | |
| 6 | 21 |
| 7 abstract class int implements num { | 22 /** The bit-wise or operator. */ |
| 8 // Bit-operations. | |
| 9 int operator &(int other); | |
| 10 int operator |(int other); | 23 int operator |(int other); |
| 24 | |
| 25 /** The bit-wise xor operator. */ | |
| 11 int operator ^(int other); | 26 int operator ^(int other); |
| 27 | |
| 28 /** The bit-wise negate operator. */ | |
| 12 int operator ~(); | 29 int operator ~(); |
| 30 | |
| 31 /** The left shift operator. */ | |
| 13 int operator <<(int shiftAmount); | 32 int operator <<(int shiftAmount); |
| 33 | |
| 34 /** The right shift operator. */ | |
| 14 int operator >>(int shiftAmount); | 35 int operator >>(int shiftAmount); |
| 15 | 36 |
| 16 // Testers. | 37 /** Returns true if and only if this integer is even. */ |
| 17 bool isEven(); | 38 bool isEven(); |
| 39 | |
| 40 /** Returns true if and only if this integer is odd. */ | |
| 18 bool isOdd(); | 41 bool isOdd(); |
| 19 | 42 |
| 20 // Specializations of super-interface. | 43 /** Negate operator. Negating an integer produces an integer. */ |
| 21 int operator -(); | 44 int operator -(); |
| 45 | |
| 46 /** Returns the absolute value of this integer. */ | |
| 22 int abs(); | 47 int abs(); |
| 48 | |
| 49 /** For integers the round method is the identify function. */ | |
| 23 int round(); | 50 int round(); |
| 51 | |
| 52 /** For integers the floor method is the identify function. */ | |
| 24 int floor(); | 53 int floor(); |
| 54 | |
| 55 /** For integers the ceil method is the identify function. */ | |
| 25 int ceil(); | 56 int ceil(); |
| 57 | |
| 58 /** 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!
| |
| 26 int truncate(); | 59 int truncate(); |
| 60 | |
| 27 /** | 61 /** |
| 28 * Returns a representation of this [int] value. | 62 * Returns a representation of this [int] value. |
| 29 * | 63 * |
| 30 * It should always be the case that if 'i' is an [int] value, then | 64 * It should always be the case that if [:i:] is an [int] value, |
| 31 * [:i == int.parse(i.toString())]. | 65 * then [:i == int.parse(i.toString()):]. |
| 32 */ | 66 */ |
| 33 String toString(); | 67 String toString(); |
| 34 | 68 |
| 35 /** | 69 /** |
| 36 * Parse [source] as an integer literal and return its value. | 70 * Parse [source] as an integer literal and return its value. |
| 37 * | 71 * |
| 38 * Accepts "0x" prefix for hexadecimal numbers, otherwise defaults | 72 * Accepts "0x" prefix for hexadecimal numbers, otherwise defaults |
| 39 * to base-10. | 73 * to base-10. |
| 74 * | |
| 40 * Throws a [FormatException] if [source] is not a valid integer literal. | 75 * Throws a [FormatException] if [source] is not a valid integer literal. |
| 41 */ | 76 */ |
| 42 external static int parse(String source); | 77 external static int parse(String source); |
| 43 } | 78 } |
| OLD | NEW |