Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Unified Diff: sdk/lib/core/double.dart

Issue 15333006: Rewrite double.parse. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Upload Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/lib/js_helper.dart ('k') | tests/co19/co19-dart2js.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/double.dart
diff --git a/sdk/lib/core/double.dart b/sdk/lib/core/double.dart
index 65b9c3096ed87dacce8d40d51f29c4892a466eca..d07e9c21d034f65c36a57a1d372478e0f2694765 100644
--- a/sdk/lib/core/double.dart
+++ b/sdk/lib/core/double.dart
@@ -133,16 +133,32 @@ 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+] :]
- *
- * Also recognizes "NaN", "Infinity" and "-Infinity" as inputs and
- * returns the corresponding double value.
- *
- * If the [soure] is not a valid double literal, the [handleError]
+ * Accepts an optional sign (`+` or `-`) followed by either the characters
+ * "Infinity", the characters "NaN" or a floating-point representation.
+ * A floating-point representation is composed of a mantissa and an optional
+ * exponent part. The mantissa is either a decimal point (`.`) followed by a
+ * sequence of (decimal) digits, or a sequence of digits
+ * optionally followed by a decimal point and optionally more digits. The
+ * (optional) exponent part consists of the character "e" or "E", an optional
+ * sign, and one or more digits.
+ *
+ * The input string is trimmed (see [String.trim]) before conversion.
+ *
+ * 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)]);
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/lib/js_helper.dart ('k') | tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698