Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 const UnsupportedOperationException( | 9 throw const UnsupportedOperationException( |
| 10 "IntegerImplementation can only be allocated by the VM"); | 10 "IntegerImplementation can only be allocated by the VM"); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 | 111 |
| 112 int round() { return this; } | 112 int round() { return this; } |
| 113 int floor() { return this; } | 113 int floor() { return this; } |
| 114 int ceil() { return this; } | 114 int ceil() { return this; } |
| 115 int truncate() { return this; } | 115 int truncate() { return this; } |
| 116 | 116 |
| 117 int toInt() { return this; } | 117 int toInt() { return this; } |
| 118 double toDouble() { return new Double.fromInteger(this); } | 118 double toDouble() { return new Double.fromInteger(this); } |
| 119 | 119 |
| 120 int pow(int exponent) { | 120 int pow(int exponent) { |
| 121 throw "IntegerImplementation.pow not implemented"; | 121 double res = this.toDouble().pow(exponent); |
|
siva
2012/02/22 01:10:43
our Bigint to double conversion is not implemented
srdjan
2012/02/22 01:38:59
Done.
| |
| 122 if (res.isInfinite()) { | |
| 123 // Use Bigint instead. | |
| 124 throw "IntegerImplementation.pow not implemented for large integers."; | |
| 125 } | |
| 126 return res.toInt(); | |
| 122 } | 127 } |
| 123 | 128 |
| 124 String toStringAsFixed(int fractionDigits) { | 129 String toStringAsFixed(int fractionDigits) { |
| 125 // Issue 460. | 130 // Issue 460. |
| 126 throw "IntegerImplementation.toStringAsFixed not implemented"; | 131 throw "IntegerImplementation.toStringAsFixed not implemented"; |
| 127 } | 132 } |
| 128 String toStringAsExponential(int fractionDigits) { | 133 String toStringAsExponential(int fractionDigits) { |
| 129 // Issue 460. | 134 // Issue 460. |
| 130 throw "IntegerImplementation.toStringAsExponential not implemented"; | 135 throw "IntegerImplementation.toStringAsExponential not implemented"; |
| 131 } | 136 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 213 if (other < 0) { | 218 if (other < 0) { |
| 214 return -1; | 219 return -1; |
| 215 } else { | 220 } else { |
| 216 return 0; | 221 return 0; |
| 217 } | 222 } |
| 218 } | 223 } |
| 219 int shlFromInt(int other) { | 224 int shlFromInt(int other) { |
| 220 throw const OutOfMemoryException(); | 225 throw const OutOfMemoryException(); |
| 221 } | 226 } |
| 222 } | 227 } |
| OLD | NEW |