Index: sdk/lib/core/double.dart |
diff --git a/sdk/lib/core/double.dart b/sdk/lib/core/double.dart |
index 65b9c3096ed87dacce8d40d51f29c4892a466eca..781b9d5dc1dfec1a0fdc48f5ffeb6ba89dcc4406 100644 |
--- a/sdk/lib/core/double.dart |
+++ b/sdk/lib/core/double.dart |
@@ -133,16 +133,33 @@ abstract class double extends num { |
/** |
* Parse [source] as an double literal and return its value. |
* |
- * Accepts the same format as double literals: |
- * [: ['+'|'-'] [digit* '.'] digit+ [('e'|'E') ['+'|'-'] digit+] :] |
+ * Accepts the following format: |
+ * `/^\s*[+-]?(?:Infinity|NaN|(?:\.\d+|\d+(?:\.\d*)?)(?:[eE][+-]?\d+)?)\s*$`. |
Lasse Reichstein Nielsen
2013/05/21 06:12:09
Don't use RegExp as specification. It's unreadable
floitsch
2013/05/21 14:39:31
Removed the regexp.
As discussed keeping the new b
|
* |
- * Also recognizes "NaN", "Infinity" and "-Infinity" as inputs and |
- * returns the corresponding double value. |
+ * In English this equals an optional sign followed by either, "Infinity", |
+ * "NaN" or a double number. A double number is composed of the mantissa and |
Lasse Reichstein Nielsen
2013/05/21 06:12:09
This accepts -NaN, which is meaningless. Please av
floitsch
2013/05/21 14:39:31
As discussed. keeping.
|
+ * and optional exponent part. The mantissa is either a dot followed by a |
+ * sequence of digits, or a sequence of digits optionally followed by a dot |
+ * and more digits. The (optional) exponent part consists of the character |
+ * "e" or "E", an optional sign, and the exponent digits. |
* |
- * If the [soure] is not a valid double literal, the [handleError] |
+ * The whole double may be surrounded by whitespace. |
+ * |
+ * If the [source] is not a valid double literal, the [handleError] |
* is called with the [source] as argument, and its return value is |
* used instead. If no handleError is provided, a [FormatException] |
* is thrown. |
+ * |
+ * Examples of accepted strings: |
+ * |
+ * "3.14" |
+ * " 3.14 \xA0" |
+ * "0." |
+ * ".0" |
+ * "-1.e3" |
+ * "1234E+7" |
+ * "+.12e-9" |
+ * "-NaN" |
*/ |
external static double parse(String source, |
[double handleError(String source)]); |