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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 * (-3).bitLength == 2; // 11111101 | 163 * (-3).bitLength == 2; // 11111101 |
164 * (-4).bitLength == 2; // 11111100 | 164 * (-4).bitLength == 2; // 11111100 |
165 */ | 165 */ |
166 int get bitLength; | 166 int get bitLength; |
167 | 167 |
168 /** | 168 /** |
169 * Returns the least significant [width] bits of this integer as a | 169 * Returns the least significant [width] bits of this integer as a |
170 * non-negative number (i.e. unsigned representation). The returned value has | 170 * non-negative number (i.e. unsigned representation). The returned value has |
171 * zeros in all bit positions higher than [width]. | 171 * zeros in all bit positions higher than [width]. |
172 * | 172 * |
173 * (-1).toUnsigned(5) == 32 // 11111111 -> 00011111 | 173 * (-1).toUnsigned(5) == 31 // 11111111 -> 00011111 |
174 * | 174 * |
175 * This operation can be used to simulate arithmetic from low level languages. | 175 * This operation can be used to simulate arithmetic from low level languages. |
176 * For example, to increment an 8 bit quantity: | 176 * For example, to increment an 8 bit quantity: |
177 * | 177 * |
178 * q = (q + 1).toUnsigned(8); | 178 * q = (q + 1).toUnsigned(8); |
179 * | 179 * |
180 * `q` will count from `0` up to `255` and then wrap around to `0`. | 180 * `q` will count from `0` up to `255` and then wrap around to `0`. |
181 * | 181 * |
182 * If the input fits in [width] bits without truncation, the result is the | 182 * If the input fits in [width] bits without truncation, the result is the |
183 * same as the input. The minimum width needed to avoid truncation of `x` is | 183 * same as the input. The minimum width needed to avoid truncation of `x` is |
(...skipping 127 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 |