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

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

Issue 12317107: ceil/floor/truncate/round return integers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reupload due to error3 Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/lib/double.dart ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // TODO(srdjan): fix limitations. 5 // TODO(srdjan): fix limitations.
6 // - shift amount must be a Smi. 6 // - shift amount must be a Smi.
7 class _IntegerImplementation { 7 class _IntegerImplementation {
8 factory _IntegerImplementation._uninstantiable() { 8 factory _IntegerImplementation._uninstantiable() {
9 throw new UnsupportedError( 9 throw new UnsupportedError(
10 "_IntegerImplementation can only be allocated by the VM"); 10 "_IntegerImplementation can only be allocated by the VM");
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } else { 124 } else {
125 return EQUAL; 125 return EQUAL;
126 } 126 }
127 } 127 }
128 128
129 int round() { return this; } 129 int round() { return this; }
130 int floor() { return this; } 130 int floor() { return this; }
131 int ceil() { return this; } 131 int ceil() { return this; }
132 int truncate() { return this; } 132 int truncate() { return this; }
133 133
134 double roundToDouble() { return this.toDouble(); }
135 double floorToDouble() { return this.toDouble(); }
136 double ceilToDouble() { return this.toDouble(); }
137 double truncateToDouble() { return this.toDouble(); }
138
134 num clamp(num lowerLimit, num upperLimit) { 139 num clamp(num lowerLimit, num upperLimit) {
135 if (lowerLimit is! num) throw new ArgumentError(lowerLimit); 140 if (lowerLimit is! num) throw new ArgumentError(lowerLimit);
136 if (upperLimit is! num) throw new ArgumentError(upperLimit); 141 if (upperLimit is! num) throw new ArgumentError(upperLimit);
137 142
138 // Special case for integers. 143 // Special case for integers.
139 if (lowerLimit is int && upperLimit is int) { 144 if (lowerLimit is int && upperLimit is int) {
140 if (lowerLimit > upperLimit) { 145 if (lowerLimit > upperLimit) {
141 throw new ArgumentError(lowerLimit); 146 throw new ArgumentError(lowerLimit);
142 } 147 }
143 if (this < lowerLimit) return lowerLimit; 148 if (this < lowerLimit) return lowerLimit;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 268 }
264 } 269 }
265 int _shlFromInt(int other) { 270 int _shlFromInt(int other) {
266 throw const OutOfMemoryError(); 271 throw const OutOfMemoryError();
267 } 272 }
268 273
269 int pow(int exponent) { 274 int pow(int exponent) {
270 throw "Bigint.pow not implemented"; 275 throw "Bigint.pow not implemented";
271 } 276 }
272 } 277 }
OLDNEW
« no previous file with comments | « runtime/lib/double.dart ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698