OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // Copyright 2009 The Go Authors. All rights reserved. | 5 // Copyright 2009 The Go Authors. All rights reserved. |
6 // Use of this source code is governed by a BSD-style | 6 // Use of this source code is governed by a BSD-style |
7 // license that can be found in the LICENSE file. | 7 // license that can be found in the LICENSE file. |
8 | 8 |
9 /* | 9 /* |
10 * Copyright (c) 2003-2005 Tom Wu | 10 * Copyright (c) 2003-2005 Tom Wu |
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 } | 1252 } |
1253 return other._toBigint()._lShift(shift)._toValidInt(); | 1253 return other._toBigint()._lShift(shift)._toValidInt(); |
1254 } | 1254 } |
1255 | 1255 |
1256 // Overriden operators and methods. | 1256 // Overriden operators and methods. |
1257 | 1257 |
1258 // The following operators override operators of _IntegerImplementation for | 1258 // The following operators override operators of _IntegerImplementation for |
1259 // efficiency, but are not necessary for correctness. They shortcut native | 1259 // efficiency, but are not necessary for correctness. They shortcut native |
1260 // calls that would return null because the receiver is _Bigint. | 1260 // calls that would return null because the receiver is _Bigint. |
1261 num operator +(num other) { | 1261 num operator +(num other) { |
1262 return other._toBigintOrDouble()._addFromInteger(this); | 1262 return other._toBigintIfInteger()._addFromInteger(this); |
1263 } | 1263 } |
1264 num operator -(num other) { | 1264 num operator -(num other) { |
1265 return other._toBigintOrDouble()._subFromInteger(this); | 1265 return other._toBigintIfInteger()._subFromInteger(this); |
1266 } | 1266 } |
1267 num operator *(num other) { | 1267 num operator *(num other) { |
1268 return other._toBigintOrDouble()._mulFromInteger(this); | 1268 return other._toBigintIfInteger()._mulFromInteger(this); |
1269 } | 1269 } |
1270 num operator ~/(num other) { | 1270 num operator ~/(num other) { |
1271 return other._toBigintOrDouble()._truncDivFromInteger(this); | 1271 return other._toBigintIfInteger()._truncDivFromInteger(this); |
1272 } | 1272 } |
1273 num operator %(num other) { | 1273 num operator %(num other) { |
1274 return other._toBigintOrDouble()._moduloFromInteger(this); | 1274 return other._toBigintIfInteger()._moduloFromInteger(this); |
1275 } | 1275 } |
1276 int operator &(int other) { | 1276 int operator &(int other) { |
1277 return other._toBigintOrDouble()._bitAndFromInteger(this); | 1277 return other._toBigintIfInteger()._bitAndFromInteger(this); |
1278 } | 1278 } |
1279 int operator |(int other) { | 1279 int operator |(int other) { |
1280 return other._toBigintOrDouble()._bitOrFromInteger(this); | 1280 return other._toBigintIfInteger()._bitOrFromInteger(this); |
1281 } | 1281 } |
1282 int operator ^(int other) { | 1282 int operator ^(int other) { |
1283 return other._toBigintOrDouble()._bitXorFromInteger(this); | 1283 return other._toBigintIfInteger()._bitXorFromInteger(this); |
1284 } | 1284 } |
1285 int operator >>(int other) { | 1285 int operator >>(int other) { |
1286 return other._toBigintOrDouble()._shrFromInt(this); | 1286 return other._toBigintIfInteger()._shrFromInt(this); |
1287 } | 1287 } |
1288 int operator <<(int other) { | 1288 int operator <<(int other) { |
1289 return other._toBigintOrDouble()._shlFromInt(this); | 1289 return other._toBigintIfInteger()._shlFromInt(this); |
1290 } | 1290 } |
1291 // End of operator shortcuts. | 1291 // End of operator shortcuts. |
1292 | 1292 |
1293 int operator -() { | 1293 int operator -() { |
1294 return _negate()._toValidInt(); | 1294 return _negate()._toValidInt(); |
1295 } | 1295 } |
1296 | 1296 |
1297 int get sign { | 1297 int get sign { |
1298 return (_used == 0) ? 0 : _neg ? -1 : 1; | 1298 return (_used == 0) ? 0 : _neg ? -1 : 1; |
1299 } | 1299 } |
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2082 | 2082 |
2083 int _mul(Uint32List x_digits, int x_used, | 2083 int _mul(Uint32List x_digits, int x_used, |
2084 Uint32List y_digits, int y_used, | 2084 Uint32List y_digits, int y_used, |
2085 Uint32List r_digits) { | 2085 Uint32List r_digits) { |
2086 var r_used = _Bigint._mulDigits(x_digits, x_used, | 2086 var r_used = _Bigint._mulDigits(x_digits, x_used, |
2087 y_digits, y_used, | 2087 y_digits, y_used, |
2088 r_digits); | 2088 r_digits); |
2089 return _reduce(r_digits, r_used); | 2089 return _reduce(r_digits, r_used); |
2090 } | 2090 } |
2091 } | 2091 } |
OLD | NEW |