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 part of fixnum; | 5 part of fixnum; |
6 | 6 |
7 /** | 7 /** |
8 * An immutable 64-bit signed integer, in the range [-2^63, 2^63 - 1]. | 8 * An immutable 64-bit signed integer, in the range [-2^63, 2^63 - 1]. |
9 * Arithmetic operations may overflow in order to maintain this range. | 9 * Arithmetic operations may overflow in order to maintain this range. |
10 */ | 10 */ |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 int64.fromInts(int top, int bottom) { | 235 int64.fromInts(int top, int bottom) { |
236 top &= 0xffffffff; | 236 top &= 0xffffffff; |
237 bottom &= 0xffffffff; | 237 bottom &= 0xffffffff; |
238 _l = bottom & _MASK; | 238 _l = bottom & _MASK; |
239 _m = ((top & 0xfff) << 10) | ((bottom >> _BITS) & 0x3ff); | 239 _m = ((top & 0xfff) << 10) | ((bottom >> _BITS) & 0x3ff); |
240 _h = (top >> 12) & _MASK_2; | 240 _h = (top >> 12) & _MASK_2; |
241 } | 241 } |
242 | 242 |
243 int64 _promote(other) { | 243 int64 _promote(other) { |
244 if (other == null) { | 244 if (other == null) { |
245 throw new NullPointerException(); | 245 throw new ArgumentError(null); |
246 } else if (other is intx) { | 246 } else if (other is intx) { |
247 other = other.toInt64(); | 247 other = other.toInt64(); |
248 } else if (other is int) { | 248 } else if (other is int) { |
249 other = new int64.fromInt(other); | 249 other = new int64.fromInt(other); |
250 } | 250 } |
251 if (other is !int64) { | 251 if (other is !int64) { |
252 throw new Exception("Can't promote $other to int64"); | 252 throw new Exception("Can't promote $other to int64"); |
253 } | 253 } |
254 return other; | 254 return other; |
255 } | 255 } |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1088 } | 1088 } |
1089 } | 1089 } |
1090 return ZERO; | 1090 return ZERO; |
1091 } | 1091 } |
1092 | 1092 |
1093 // Generate the quotient using bit-at-a-time long division. | 1093 // Generate the quotient using bit-at-a-time long division. |
1094 return _divModHelper(aIsCopy ? a : new int64._copy(a), b, negative, | 1094 return _divModHelper(aIsCopy ? a : new int64._copy(a), b, negative, |
1095 aIsNegative, aIsMinValue, computeRemainder); | 1095 aIsNegative, aIsMinValue, computeRemainder); |
1096 } | 1096 } |
1097 } | 1097 } |
OLD | NEW |