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

Unified Diff: runtime/lib/double.dart

Issue 11748016: Make ~/, round, ceil, floor, truncate return ints. Remove toInt. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Checked mode fixes. Created 7 years, 12 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/double.dart
diff --git a/runtime/lib/double.dart b/runtime/lib/double.dart
index 8d4699180f2c45d116f8c54a17822dc6f5863ba5..ec2f9765f9baa8df4ab737c7ac2768d68b6fbf34 100644
--- a/runtime/lib/double.dart
+++ b/runtime/lib/double.dart
@@ -7,7 +7,7 @@ class _Double implements double {
native "Double_doubleFromInteger";
int get hashCode {
try {
- return toInt();
+ return truncate();
} on FormatException catch (e) {
return 0;
}
@@ -27,10 +27,10 @@ class _Double implements double {
}
double _mul(double other) native "Double_mul";
- double operator ~/(num other) {
+ int operator ~/(num other) {
return _trunc_div(other.toDouble());
}
- double _trunc_div(double other) native "Double_trunc_div";
+ int _trunc_div(double other) native "Double_trunc_div";
double operator /(num other) {
return _div(other.toDouble());
@@ -81,7 +81,7 @@ class _Double implements double {
double _mulFromInteger(int other) {
return new _Double.fromInteger(other) * this;
}
- double _truncDivFromInteger(int other) {
+ int _truncDivFromInteger(int other) {
return new _Double.fromInteger(other) ~/ this;
}
double _moduloFromInteger(int other) {
@@ -103,10 +103,10 @@ class _Double implements double {
return this < 0.0 ? -this : this;
}
- double round() native "Double_round";
- double floor() native "Double_floor";
- double ceil () native "Double_ceil";
- double truncate() native "Double_truncate";
+ int round() native "Double_round";
+ int floor() native "Double_floor";
+ int ceil () native "Double_ceil";
+ int truncate() native "Double_truncate";
num clamp(num lowerLimit, num upperLimit) {
if (lowerLimit is! num) throw new ArgumentError(lowerLimit);
@@ -121,7 +121,6 @@ class _Double implements double {
return this;
}
- int toInt() native "Double_toInt";
double toDouble() { return this; }
double pow(num exponent) {

Powered by Google App Engine
This is Rietveld 408576698