| 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 // TODO: Convert this abstract class into a concrete class double | 7 // TODO: Convert this abstract class into a concrete class double |
| 8 // that uses the patch class functionality to account for the | 8 // that uses the patch class functionality to account for the |
| 9 // different platform implementations. | 9 // different platform implementations. |
| 10 | 10 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 * Returns "-0.0" for negative zero. | 126 * Returns "-0.0" for negative zero. |
| 127 * | 127 * |
| 128 * It should always be the case that if [:d:] is a [double], then | 128 * It should always be the case that if [:d:] is a [double], then |
| 129 * [:d == double.parse(d.toString()):]. | 129 * [:d == double.parse(d.toString()):]. |
| 130 */ | 130 */ |
| 131 String toString(); | 131 String toString(); |
| 132 | 132 |
| 133 /** | 133 /** |
| 134 * Parse [source] as an double literal and return its value. | 134 * Parse [source] as an double literal and return its value. |
| 135 * | 135 * |
| 136 * Accepts an optional sign (`+` or `-`) followed by either the characters | 136 * Accepts the same format as double literals: |
| 137 * "Infinity", the characters "NaN" or a floating-point representation. | 137 * [: ['+'|'-'] [digit* '.'] digit+ [('e'|'E') ['+'|'-'] digit+] :] |
| 138 * A floating-point representation is composed of a mantissa and an optional | |
| 139 * exponent part. The mantissa is either a decimal point (`.`) followed by a | |
| 140 * sequence of (decimal) digits, or a sequence of digits | |
| 141 * optionally followed by a decimal point and optionally more digits. The | |
| 142 * (optional) exponent part consists of the character "e" or "E", an optional | |
| 143 * sign, and one or more digits. | |
| 144 * | 138 * |
| 145 * The input string is trimmed (see [String.trim]) before conversion. | 139 * Also recognizes "NaN", "Infinity" and "-Infinity" as inputs and |
| 140 * returns the corresponding double value. |
| 146 * | 141 * |
| 147 * If the [source] is not a valid double literal, the [handleError] | 142 * If the [soure] is not a valid double literal, the [handleError] |
| 148 * is called with the [source] as argument, and its return value is | 143 * is called with the [source] as argument, and its return value is |
| 149 * used instead. If no handleError is provided, a [FormatException] | 144 * used instead. If no handleError is provided, a [FormatException] |
| 150 * is thrown. | 145 * is thrown. |
| 151 * | |
| 152 * Examples of accepted strings: | |
| 153 * | |
| 154 * "3.14" | |
| 155 * " 3.14 \xA0" | |
| 156 * "0." | |
| 157 * ".0" | |
| 158 * "-1.e3" | |
| 159 * "1234E+7" | |
| 160 * "+.12e-9" | |
| 161 * "-NaN" | |
| 162 */ | 146 */ |
| 163 external static double parse(String source, | 147 external static double parse(String source, |
| 164 [double handleError(String source)]); | 148 [double handleError(String source)]); |
| 165 } | 149 } |
| OLD | NEW |