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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 throw "Bad radix: $radix"; | 123 throw "Bad radix: $radix"; |
124 } | 124 } |
125 int64 x = ZERO; | 125 int64 x = ZERO; |
126 int i = 0; | 126 int i = 0; |
127 bool negative = false; | 127 bool negative = false; |
128 if (s[0] == '-') { | 128 if (s[0] == '-') { |
129 negative = true; | 129 negative = true; |
130 i++; | 130 i++; |
131 } | 131 } |
132 for (; i < s.length; i++) { | 132 for (; i < s.length; i++) { |
133 int c = s.charCodeAt(i); | 133 int c = s.codeUnitAt(i); |
134 int digit = int32._decodeHex(c); | 134 int digit = int32._decodeHex(c); |
135 if (digit < 0 || digit >= radix) { | 135 if (digit < 0 || digit >= radix) { |
136 throw new Exception("Non-radix char code: $c"); | 136 throw new Exception("Non-radix char code: $c"); |
137 } | 137 } |
138 x = (x * radix) + digit; | 138 x = (x * radix) + digit; |
139 } | 139 } |
140 return negative ? -x : x; | 140 return negative ? -x : x; |
141 } | 141 } |
142 | 142 |
143 /** | 143 /** |
(...skipping 944 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 |