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

Side by Side Diff: runtime/lib/double.dart

Issue 8598021: Remove isOdd/isEven from num and double interfaces. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class Double implements double { 5 class Double implements double {
6 factory Double.fromInteger(int value) 6 factory Double.fromInteger(int value)
7 native "Double_doubleFromInteger"; 7 native "Double_doubleFromInteger";
8 int hashCode() { 8 int hashCode() {
9 try { 9 try {
10 return toInt(); 10 return toInt();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 double moduloFromInteger(int other) { 84 double moduloFromInteger(int other) {
85 return new Double.fromInteger(other) % this; 85 return new Double.fromInteger(other) % this;
86 } 86 }
87 double remainderFromInteger(int other) { 87 double remainderFromInteger(int other) {
88 return new Double.fromInteger(other).remainder(this); 88 return new Double.fromInteger(other).remainder(this);
89 } 89 }
90 90
91 bool greaterThanFromInteger(int other) native "Double_greaterThanFromInteger"; 91 bool greaterThanFromInteger(int other) native "Double_greaterThanFromInteger";
92 92
93 bool isEven() {
94 // TODO(floitsch): find more efficient way to implement Double.isEven.
95 return this % 2.0 == 0.0;
96 }
97 bool isOdd() {
98 // TODO(floitsch): find more efficient way to implement Double.isOdd.
99 return this % 2.0 == 1.0;
100 }
101 bool isNegative() native "Double_isNegative"; 93 bool isNegative() native "Double_isNegative";
102 bool isInfinite() native "Double_isInfinite"; 94 bool isInfinite() native "Double_isInfinite";
103 bool isNaN() native "Double_isNaN"; 95 bool isNaN() native "Double_isNaN";
104 96
105 double abs() { 97 double abs() {
106 // Handle negative 0.0. 98 // Handle negative 0.0.
107 if (this == 0.0) return 0.0; 99 if (this == 0.0) return 0.0;
108 return this < 0.0 ? -this : this; 100 return this < 0.0 ? -this : this;
109 } 101 }
110 102
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 return EQUAL; 206 return EQUAL;
215 } 207 }
216 } else if (isNaN()) { 208 } else if (isNaN()) {
217 return other.isNaN() ? EQUAL : GREATER; 209 return other.isNaN() ? EQUAL : GREATER;
218 } else { 210 } else {
219 // Other is NaN. 211 // Other is NaN.
220 return LESS; 212 return LESS;
221 } 213 }
222 } 214 }
223 } 215 }
OLDNEW
« corelib/src/num.dart ('K') | « corelib/src/num.dart ('k') | tests/co19/co19-runtime.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698