| 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 abstract class _IntegerImplementation { | 5 abstract class _IntegerImplementation { |
| 6 // The Dart class _Bigint extending _IntegerImplementation requires a | 6 // The Dart class _Bigint extending _IntegerImplementation requires a |
| 7 // default constructor. | 7 // default constructor. |
| 8 | 8 |
| 9 Type get runtimeType => int; | 9 Type get runtimeType => int; |
| 10 | 10 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 _OneByteString string = _OneByteString._allocate(length); | 256 _OneByteString string = _OneByteString._allocate(length); |
| 257 string._setAt(0, 0x2d); // '-'. Is overwritten if not negative. | 257 string._setAt(0, 0x2d); // '-'. Is overwritten if not negative. |
| 258 var mask = radix - 1; | 258 var mask = radix - 1; |
| 259 do { | 259 do { |
| 260 string._setAt(--length, _digits.codeUnitAt(value & mask)); | 260 string._setAt(--length, _digits.codeUnitAt(value & mask)); |
| 261 value >>= bitsPerDigit; | 261 value >>= bitsPerDigit; |
| 262 } while (value > 0); | 262 } while (value > 0); |
| 263 return string; | 263 return string; |
| 264 } | 264 } |
| 265 | 265 |
| 266 _leftShiftWithMask32(count, mask) native "Integer_leftShiftWithMask32"; | |
| 267 | |
| 268 // Returns pow(this, e) % m. | 266 // Returns pow(this, e) % m. |
| 269 int modPow(int e, int m) { | 267 int modPow(int e, int m) { |
| 270 if (e is! int) { | 268 if (e is! int) { |
| 271 throw new ArgumentError.value(e, "exponent", "not an integer"); | 269 throw new ArgumentError.value(e, "exponent", "not an integer"); |
| 272 } | 270 } |
| 273 if (m is! int) { | 271 if (m is! int) { |
| 274 throw new ArgumentError.value(m, "modulus", "not an integer"); | 272 throw new ArgumentError.value(m, "modulus", "not an integer"); |
| 275 } | 273 } |
| 276 if (e < 0) throw new RangeError.range(e, 0, null, "exponent"); | 274 if (e < 0) throw new RangeError.range(e, 0, null, "exponent"); |
| 277 if (m <= 0) throw new RangeError.range(m, 1, null, "modulus"); | 275 if (m <= 0) throw new RangeError.range(m, 1, null, "modulus"); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 // Shift by mint exceeds range that can be handled by the VM. | 613 // Shift by mint exceeds range that can be handled by the VM. |
| 616 int _shrFromInt(int other) { | 614 int _shrFromInt(int other) { |
| 617 if (other < 0) { | 615 if (other < 0) { |
| 618 return -1; | 616 return -1; |
| 619 } else { | 617 } else { |
| 620 return 0; | 618 return 0; |
| 621 } | 619 } |
| 622 } | 620 } |
| 623 int _shlFromInt(int other) native "Mint_shlFromInt"; | 621 int _shlFromInt(int other) native "Mint_shlFromInt"; |
| 624 } | 622 } |
| OLD | NEW |