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

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

Issue 559203003: Fix wrong conversion from double to bigint in overriden operators of new bigint. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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/object.cc » ('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 extends _Num { 7 class _IntegerImplementation extends _Num {
8 // The Dart class _Bigint extending _IntegerImplementation requires a 8 // The Dart class _Bigint extending _IntegerImplementation requires a
9 // default constructor. 9 // default constructor.
10 10
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 if (lowerLimit.isNaN) return lowerLimit; 194 if (lowerLimit.isNaN) return lowerLimit;
195 // Note that we don't need to care for -0.0 for the lower limit. 195 // Note that we don't need to care for -0.0 for the lower limit.
196 if (this < lowerLimit) return lowerLimit; 196 if (this < lowerLimit) return lowerLimit;
197 if (this.compareTo(upperLimit) > 0) return upperLimit; 197 if (this.compareTo(upperLimit) > 0) return upperLimit;
198 return this; 198 return this;
199 } 199 }
200 200
201 int toInt() { return this; } 201 int toInt() { return this; }
202 double toDouble() { return new _Double.fromInteger(this); } 202 double toDouble() { return new _Double.fromInteger(this); }
203 _Bigint _toBigint() { return new _Bigint()._setInt(this); } 203 _Bigint _toBigint() { return new _Bigint()._setInt(this); }
204 num _toBigintOrDouble() { return _toBigint(); }
204 205
205 String toStringAsFixed(int fractionDigits) { 206 String toStringAsFixed(int fractionDigits) {
206 return this.toDouble().toStringAsFixed(fractionDigits); 207 return this.toDouble().toStringAsFixed(fractionDigits);
207 } 208 }
208 String toStringAsExponential([int fractionDigits]) { 209 String toStringAsExponential([int fractionDigits]) {
209 return this.toDouble().toStringAsExponential(fractionDigits); 210 return this.toDouble().toStringAsExponential(fractionDigits);
210 } 211 }
211 String toStringAsPrecision(int precision) { 212 String toStringAsPrecision(int precision) {
212 return this.toDouble().toStringAsPrecision(precision); 213 return this.toDouble().toStringAsPrecision(precision);
213 } 214 }
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 // Shift by mint exceeds range that can be handled by the VM. 477 // Shift by mint exceeds range that can be handled by the VM.
477 int _shrFromInt(int other) { 478 int _shrFromInt(int other) {
478 if (other < 0) { 479 if (other < 0) {
479 return -1; 480 return -1;
480 } else { 481 } else {
481 return 0; 482 return 0;
482 } 483 }
483 } 484 }
484 int _shlFromInt(int other) native "Mint_shlFromInt"; 485 int _shlFromInt(int other) native "Mint_shlFromInt";
485 } 486 }
OLDNEW
« no previous file with comments | « runtime/lib/double.dart ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698