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

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

Issue 2005723004: Fraction class prototype and test (not to be committed). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: work in progress Created 4 years, 5 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 | « runtime/vm/token.h ('k') | tests/language/vm/fraction_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/num.dart
diff --git a/sdk/lib/core/num.dart b/sdk/lib/core/num.dart
index 21f23eef18321ab7fc4b59aa397cdbb7ead0b0d6..c18d734c8431544eb8251a958eda20532ab7103c 100644
--- a/sdk/lib/core/num.dart
+++ b/sdk/lib/core/num.dart
@@ -106,7 +106,7 @@ abstract class num implements Comparable<num> {
num operator %(num other);
/** Division operator. */
- double operator /(num other);
+ num operator /(num other);
/**
* Truncating division operator.
@@ -311,6 +311,14 @@ abstract class num implements Comparable<num> {
*/
double toDouble();
+ /** Return this [num] as a [fraction]. */
+ fraction toFraction();
+
+ /** Return this [num] as a [fraction] with 100 as the
+ * denominator. Precision loss may occur. Infinite and NaN
+ * are not supported. */
+ fraction toPercent();
+
/**
* Returns a decimal-point string-representation of `this`.
*
« no previous file with comments | « runtime/vm/token.h ('k') | tests/language/vm/fraction_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698