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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 */ | 239 */ |
240 String toRadixString(int radix); | 240 String toRadixString(int radix); |
241 | 241 |
242 /** | 242 /** |
243 * Parse [source] as an integer literal and return its value. | 243 * Parse [source] as an integer literal and return its value. |
244 * | 244 * |
245 * The [radix] must be in the range 2..36. The digits used are | 245 * The [radix] must be in the range 2..36. The digits used are |
246 * first the decimal digits 0..9, and then the letters 'a'..'z'. | 246 * first the decimal digits 0..9, and then the letters 'a'..'z'. |
247 * Accepts capital letters as well. | 247 * Accepts capital letters as well. |
248 * | 248 * |
249 * If no [radix] is given then it defaults to 16 if the string starts | 249 * If no [radix] is given then it defaults to 10, unless the string starts |
250 * with "0x", "-0x" or "+0x" and 10 otherwise. | 250 * with "0x", "-0x" or "+0x", in which case the radix is set to 16 and the |
| 251 * "0x" is ignored. |
251 * | 252 * |
252 * The [source] must be a non-empty sequence of base-[radix] digits, | 253 * The [source] must be a non-empty sequence of base-[radix] digits, |
253 * optionally prefixed with a minus or plus sign ('-' or '+'). | 254 * optionally prefixed with a minus or plus sign ('-' or '+'). |
254 * | 255 * |
255 * It must always be the case for an int [:n:] and radix [:r:] that | 256 * It must always be the case for an int [:n:] and radix [:r:] that |
256 * [:n == parseRadix(n.toRadixString(r), r):]. | 257 * [:n == parseRadix(n.toRadixString(r), r):]. |
257 * | 258 * |
258 * If the [source] is not a valid integer literal, optionally prefixed by a | 259 * If the [source] is not a valid integer literal, optionally prefixed by a |
259 * sign, the [onError] is called with the [source] as argument, and its return | 260 * sign, the [onError] is called with the [source] as argument, and its return |
260 * value is used instead. If no [onError] is provided, a [FormatException] | 261 * value is used instead. If no [onError] is provided, a [FormatException] |
261 * is thrown. | 262 * is thrown. |
262 * | 263 * |
263 * The [onError] function is only invoked if [source] is a [String]. It is | 264 * The [onError] function is only invoked if [source] is a [String]. It is |
264 * not invoked if the [source] is, for example, `null`. | 265 * not invoked if the [source] is, for example, `null`. |
265 */ | 266 */ |
266 external static int parse(String source, | 267 external static int parse(String source, |
267 { int radix, | 268 { int radix, |
268 int onError(String source) }); | 269 int onError(String source) }); |
269 } | 270 } |
OLD | NEW |