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

Unified Diff: lib/core/double.dart

Issue 10913271: Move parseInt parseDouble to int/double classes as a static method. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Make int.parse directly native. Created 8 years, 3 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 | « lib/core/core.dart ('k') | lib/core/expect.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/core/double.dart
diff --git a/lib/core/double.dart b/lib/core/double.dart
index bf6a19a7de10bf83b9476a126f0632d367b14a8e..a1c47d46e510a08f68e8237c4e59f745d0ee1b4c 100644
--- a/lib/core/double.dart
+++ b/lib/core/double.dart
@@ -8,7 +8,7 @@
// that uses the patch class functionality to account for the
// different platform implementations.
-abstract class double implements num {
+abstract class double extends num {
static const double NAN = 0.0 / 0.0;
static const double INFINITY = 1.0 / 0.0;
static const double NEGATIVE_INFINITY = -INFINITY;
@@ -28,4 +28,31 @@ abstract class double implements num {
abstract double floor();
abstract double ceil();
abstract double truncate();
+
+ /**
+ * Provide a representation of this [double] value.
+ *
+ * The representation is a number literal such that the closest double value
+ * to the representation's mathematical value is this [double].
+ *
+ * Returns "NaN" for the Not-a-Number value.
+ * Returns "Infinity" and "-Infinity" for positive and negative Infinity.
+ * Returns "-0.0" for negative zero.
+ *
+ * It should always be the case that if [:d:] is a [double], then
+ * [:d == double.parse(d.toString()):].
+ */
+ abstract String toString();
+
+ /**
+ * 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.
+ * Throws a [FormatException] if [source] is not a valid double literal.
+ */
+ external static double parse(String source);
}
« no previous file with comments | « lib/core/core.dart ('k') | lib/core/expect.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698