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); |
} |