| 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 arbitrarily large integer. | 8 * An arbitrarily large integer. |
| 9 * | 9 * |
| 10 * **Note:** When compiling to JavaScript, integers are | 10 * **Note:** When compiling to JavaScript, integers are |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 /** Returns true if and only if this integer is odd. */ | 142 /** Returns true if and only if this integer is odd. */ |
| 143 bool get isOdd; | 143 bool get isOdd; |
| 144 | 144 |
| 145 /** | 145 /** |
| 146 * Returns the minimum number of bits required to store this integer. | 146 * Returns the minimum number of bits required to store this integer. |
| 147 * | 147 * |
| 148 * The number of bits excludes the sign bit, which gives the natural length | 148 * The number of bits excludes the sign bit, which gives the natural length |
| 149 * for non-negative (unsigned) values. Negative values are complemented to | 149 * for non-negative (unsigned) values. Negative values are complemented to |
| 150 * return the bit position of the first bit that differs from the sign bit. | 150 * return the bit position of the first bit that differs from the sign bit. |
| 151 * | 151 * |
| 152 * To find the the number of bits needed to store the value as a signed value, | 152 * To find the number of bits needed to store the value as a signed value, |
| 153 * add one, i.e. use `x.bitLength + 1`. | 153 * add one, i.e. use `x.bitLength + 1`. |
| 154 * | 154 * |
| 155 * x.bitLength == (-x-1).bitLength | 155 * x.bitLength == (-x-1).bitLength |
| 156 * | 156 * |
| 157 * 3.bitLength == 2; // 00000011 | 157 * 3.bitLength == 2; // 00000011 |
| 158 * 2.bitLength == 2; // 00000010 | 158 * 2.bitLength == 2; // 00000010 |
| 159 * 1.bitLength == 1; // 00000001 | 159 * 1.bitLength == 1; // 00000001 |
| 160 * 0.bitLength == 0; // 00000000 | 160 * 0.bitLength == 0; // 00000000 |
| 161 * (-1).bitLength == 0; // 11111111 | 161 * (-1).bitLength == 0; // 11111111 |
| 162 * (-2).bitLength == 1; // 11111110 | 162 * (-2).bitLength == 1; // 11111110 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 * var value = int.parse(text, onError: (source) => null); | 311 * var value = int.parse(text, onError: (source) => null); |
| 312 * if (value == null) ... handle the problem | 312 * if (value == null) ... handle the problem |
| 313 * | 313 * |
| 314 * The [onError] function is only invoked if [source] is a [String]. It is | 314 * The [onError] function is only invoked if [source] is a [String]. It is |
| 315 * not invoked if the [source] is, for example, `null`. | 315 * not invoked if the [source] is, for example, `null`. |
| 316 */ | 316 */ |
| 317 external static int parse(String source, | 317 external static int parse(String source, |
| 318 { int radix, | 318 { int radix, |
| 319 int onError(String source) }); | 319 int onError(String source) }); |
| 320 } | 320 } |
| OLD | NEW |