Index: runtime/lib/integers.dart |
diff --git a/runtime/lib/integers.dart b/runtime/lib/integers.dart |
index 0c5b11985bad5dd6648392883097aec8ee5f26cc..22188f9929c5332f7361a4a00b987b046f634471 100644 |
--- a/runtime/lib/integers.dart |
+++ b/runtime/lib/integers.dart |
@@ -92,13 +92,16 @@ abstract class _IntegerImplementation { |
return other._greaterThanFromInteger(this); |
} |
bool operator >=(num other) { |
- return (this == other) || (this > other); |
+ return (this == other) || (this > other); |
} |
bool operator <=(num other) { |
return (this == other) || (this < other); |
} |
bool _greaterThanFromInteger(int other) |
native "Integer_greaterThanFromInteger"; |
+ bool _greaterThanFromFraction(fraction other) { |
+ return other._numerator > (other._denominator * this); |
+ } |
bool operator ==(other) { |
if (other is num) { |
return other._equalToInteger(this); |
@@ -106,6 +109,9 @@ abstract class _IntegerImplementation { |
return false; |
} |
bool _equalToInteger(int other) native "Integer_equalToInteger"; |
+ bool _equalToFraction(fraction other) { |
+ return (this * other._denominator) == other._numerator; |
+ } |
int abs() { |
return this < 0 ? -this : this; |
} |
@@ -200,8 +206,11 @@ abstract class _IntegerImplementation { |
int toInt() { return this; } |
double toDouble() { return new _Double.fromInteger(this); } |
+ fraction toFraction() { return new _Fraction.fromInteger(this); } |
+ fraction toPercent() { return new _Fraction._percent(this*100); } |
_Bigint _toBigint() { return new _Bigint._fromInt(this); } |
- num _toBigintOrDouble() { return _toBigint(); } |
+ num _toBigintIfInteger() { return _toBigint(); } |
+ num _toDoubleOrFraction() { return new _Fraction.fromInteger(this); } |
String toStringAsFixed(int fractionDigits) { |
return this.toDouble().toStringAsFixed(fractionDigits); |