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

Unified Diff: runtime/lib/integers.dart

Issue 11227042: isEven, isOdd, isNegative, isMaxValue, isMinValue, isInfinite, isPositive, isSingleValue. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. Created 8 years, 2 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
Index: runtime/lib/integers.dart
diff --git a/runtime/lib/integers.dart b/runtime/lib/integers.dart
index 9fcab19b6e9abf9a8995061db13b8b2d81eb6864..c82e090df4a76d48733b68e5d596c5b501713bb6 100644
--- a/runtime/lib/integers.dart
+++ b/runtime/lib/integers.dart
@@ -89,11 +89,11 @@ class _IntegerImplementation {
int abs() {
return this < 0 ? -this : this;
}
- bool isEven() { return ((this & 1) === 0); }
- bool isOdd() { return !isEven(); }
- bool isNaN() { return false; }
- bool isNegative() { return this < 0; }
- bool isInfinite() { return false; }
+ bool get isEven => ((this & 1) == 0);
+ bool get isOdd => !isEven;
+ bool get isNaN => false;
+ bool get isNegative => this < 0;
+ bool get isInfinite => false;
int compareTo(num other) {
final int EQUAL = 0, LESS = -1, GREATER = 1;
@@ -102,10 +102,10 @@ class _IntegerImplementation {
int MAX_EXACT_INT_TO_DOUBLE = 9007199254740992; // 2^53.
int MIN_EXACT_INT_TO_DOUBLE = -MAX_EXACT_INT_TO_DOUBLE;
double d = other;
- if (d.isInfinite()) {
+ if (d.isInfinite) {
return d == double.NEGATIVE_INFINITY ? GREATER : LESS;
}
- if (d.isNaN()) {
+ if (d.isNaN) {
return LESS;
}
if (MIN_EXACT_INT_TO_DOUBLE <= this && this <= MAX_EXACT_INT_TO_DOUBLE) {
@@ -136,7 +136,7 @@ class _IntegerImplementation {
int pow(int exponent) {
double res = this.toDouble().pow(exponent);
- if (res.isInfinite()) {
+ if (res.isInfinite) {
// Use Bigint instead.
throw "_IntegerImplementation.pow not implemented for large integers.";
}

Powered by Google App Engine
This is Rietveld 408576698