OLD | NEW |
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 5 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
6 // for details. All rights reserved. Use of this source code is governed by a | 6 // for details. All rights reserved. Use of this source code is governed by a |
7 // BSD-style license that can be found in the LICENSE file. | 7 // BSD-style license that can be found in the LICENSE file. |
8 | 8 |
9 // Copyright 2009 The Go Authors. All rights reserved. | 9 // Copyright 2009 The Go Authors. All rights reserved. |
10 // Use of this source code is governed by a BSD-style | 10 // Use of this source code is governed by a BSD-style |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 class _Uint32Digits { | 49 class _Uint32Digits { |
50 final int length; | 50 final int length; |
51 final _backing; | 51 final _backing; |
52 | 52 |
53 const _Uint32Digits(int length) | 53 const _Uint32Digits(int length) |
54 : this.length = length, _backing = _allocate(length); | 54 : this.length = length, _backing = _allocate(length); |
55 | 55 |
56 operator [](int index) => _getUint32(_backing, index); | 56 operator [](int index) => _getUint32(_backing, index); |
57 operator []=(int index, int value) => _setUint32(_backing, index, value); | 57 operator []=(int index, int value) => _setUint32(_backing, index, value); |
58 | 58 |
59 @fletch.native external static _allocate(int length); | 59 @dartino.native external static _allocate(int length); |
60 @fletch.native external static _getUint32(backing, int index); | 60 @dartino.native external static _getUint32(backing, int index); |
61 @fletch.native external static _setUint32(backing, int index, int value); | 61 @dartino.native external static _setUint32(backing, int index, int value); |
62 } | 62 } |
63 | 63 |
64 // A big integer number is represented by a sign, an array of 32-bit unsigned | 64 // A big integer number is represented by a sign, an array of 32-bit unsigned |
65 // integers in little endian format, and a number of used digits in that array. | 65 // integers in little endian format, and a number of used digits in that array. |
66 // The code makes sure that an even number of digits is always accessible and | 66 // The code makes sure that an even number of digits is always accessible and |
67 // meaningful, so that pairs of digits can be processed as 64-bit unsigned | 67 // meaningful, so that pairs of digits can be processed as 64-bit unsigned |
68 // numbers on a 64-bit platform. This requires the initialization of a leading | 68 // numbers on a 64-bit platform. This requires the initialization of a leading |
69 // zero if the number of used digits is odd. | 69 // zero if the number of used digits is odd. |
70 class _Bigint extends _IntBase { | 70 class _Bigint extends _IntBase { |
71 // Bits per digit. | 71 // Bits per digit. |
(...skipping 2092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2164 | 2164 |
2165 int _mul(_Uint32Digits x_digits, int x_used, | 2165 int _mul(_Uint32Digits x_digits, int x_used, |
2166 _Uint32Digits y_digits, int y_used, | 2166 _Uint32Digits y_digits, int y_used, |
2167 _Uint32Digits r_digits) { | 2167 _Uint32Digits r_digits) { |
2168 var r_used = _Bigint._mulDigits(x_digits, x_used, | 2168 var r_used = _Bigint._mulDigits(x_digits, x_used, |
2169 y_digits, y_used, | 2169 y_digits, y_used, |
2170 r_digits); | 2170 r_digits); |
2171 return _reduce(r_digits, r_used); | 2171 return _reduce(r_digits, r_used); |
2172 } | 2172 } |
2173 } | 2173 } |
OLD | NEW |