Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: pkg/fixnum/int32.dart

Issue 10913271: Move parseInt parseDouble to int/double classes as a static method. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Make int.parse directly native. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/uri/uri.dart ('k') | pkg/intl/lib/date_format_helpers.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « lib/uri/uri.dart ('k') | pkg/intl/lib/date_format_helpers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698