| 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 /** | 5 /** |
| 6 * An immutable 32-bit signed integer, in the range [-2^31, 2^31 - 1]. | 6 * An immutable 32-bit signed integer, in the range [-2^31, 2^31 - 1]. |
| 7 * Arithmetic operations may overflow in order to maintain this range. | 7 * Arithmetic operations may overflow in order to maintain this range. |
| 8 */ | 8 */ |
| 9 class int32 implements intx { | 9 class int32 implements intx { |
| 10 | 10 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 throw new Exception("Non-radix char code: $c"); | 72 throw new Exception("Non-radix char code: $c"); |
| 73 } | 73 } |
| 74 x = (x * radix) + digit; | 74 x = (x * radix) + digit; |
| 75 } | 75 } |
| 76 return x; | 76 return x; |
| 77 } | 77 } |
| 78 | 78 |
| 79 /** | 79 /** |
| 80 * Parses a decimal [String] and returns an [int32]. | 80 * Parses a decimal [String] and returns an [int32]. |
| 81 */ | 81 */ |
| 82 static int32 parseInt(String s) => new int32.fromInt(Math.parseInt(s)); | 82 static int32 parseInt(String s) => new int32.fromInt(int.parse(s)); |
| 83 | 83 |
| 84 /** | 84 /** |
| 85 * Parses a hexadecimal [String] and returns an [int32]. | 85 * Parses a hexadecimal [String] and returns an [int32]. |
| 86 */ | 86 */ |
| 87 static int32 parseHex(String s) => parseRadix(s, 16); | 87 static int32 parseHex(String s) => parseRadix(s, 16); |
| 88 | 88 |
| 89 // Assumes i is <= 32-bit. | 89 // Assumes i is <= 32-bit. |
| 90 static int _bitCount(int i) { | 90 static int _bitCount(int i) { |
| 91 // See "Hacker's Delight", section 5-1, "Counting 1-Bits". | 91 // See "Hacker's Delight", section 5-1, "Counting 1-Bits". |
| 92 | 92 |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 } | 345 } |
| 346 | 346 |
| 347 int toInt() => _i; | 347 int toInt() => _i; |
| 348 int32 toInt32() => this; | 348 int32 toInt32() => this; |
| 349 int64 toInt64() => new int64.fromInt(_i); | 349 int64 toInt64() => new int64.fromInt(_i); |
| 350 | 350 |
| 351 String toString() => _i.toString(); | 351 String toString() => _i.toString(); |
| 352 String toHexString() => _i.toRadixString(16); | 352 String toHexString() => _i.toRadixString(16); |
| 353 String toRadixString(int radix) => _i.toRadixString(radix); | 353 String toRadixString(int radix) => _i.toRadixString(radix); |
| 354 } | 354 } |
| OLD | NEW |