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 integer or floating-point number. | 8 * An integer or floating-point number. |
9 * | 9 * |
10 * It is a compile-time error for any type other than [int] or [double] | 10 * It is a compile-time error for any type other than [int] or [double] |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 /** | 409 /** |
410 * Returns the shortest string that correctly represent the input number. | 410 * Returns the shortest string that correctly represent the input number. |
411 * | 411 * |
412 * All [double]s in the range `10^-6` (inclusive) to `10^21` (exclusive) | 412 * All [double]s in the range `10^-6` (inclusive) to `10^21` (exclusive) |
413 * are converted to their decimal representation with at least one digit | 413 * are converted to their decimal representation with at least one digit |
414 * after the decimal point. For all other doubles, | 414 * after the decimal point. For all other doubles, |
415 * except for special values like `NaN` or `Infinity`, this method returns an | 415 * except for special values like `NaN` or `Infinity`, this method returns an |
416 * exponential representation (see [toStringAsExponential]). | 416 * exponential representation (see [toStringAsExponential]). |
417 * | 417 * |
418 * Returns `"NaN"` for [double.NAN], `"Infinity"` for [double.INFINITY], and | 418 * Returns `"NaN"` for [double.NAN], `"Infinity"` for [double.INFINITY], and |
419 * `"-Infinity"` for [double.MINUS_INFINITY]. | 419 * `"-Infinity"` for [double.NEGATIVE_INFINITY]. |
420 * | 420 * |
421 * An [int] is converted to a decimal representation with no decimal point. | 421 * An [int] is converted to a decimal representation with no decimal point. |
422 * | 422 * |
423 * Examples: | 423 * Examples: |
424 * | 424 * |
425 * (0.000001).toString(); // "0.000001" | 425 * (0.000001).toString(); // "0.000001" |
426 * (0.0000001).toString(); // "1e-7" | 426 * (0.0000001).toString(); // "1e-7" |
427 * (111111111111111111111.0).toString(); // "111111111111111110000.0" | 427 * (111111111111111111111.0).toString(); // "111111111111111110000.0" |
428 * (100000000000000000000.0).toString(); // "100000000000000000000.0" | 428 * (100000000000000000000.0).toString(); // "100000000000000000000.0" |
429 * (1000000000000000000000.0).toString(); // "1e+21" | 429 * (1000000000000000000000.0).toString(); // "1e+21" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 result = double.parse(source, _returnDoubleNull); | 471 result = double.parse(source, _returnDoubleNull); |
472 if (result != null) return result; | 472 if (result != null) return result; |
473 if (onError == null) throw new FormatException(input); | 473 if (onError == null) throw new FormatException(input); |
474 return onError(input); | 474 return onError(input); |
475 } | 475 } |
476 | 476 |
477 /** Helper functions for [parse]. */ | 477 /** Helper functions for [parse]. */ |
478 static int _returnIntNull(String _) => null; | 478 static int _returnIntNull(String _) => null; |
479 static double _returnDoubleNull(String _) => null; | 479 static double _returnDoubleNull(String _) => null; |
480 } | 480 } |
OLD | NEW |