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

Side by Side Diff: frog/lib/math.dart

Issue 9595013: parseInt fixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status file. Created 8 years, 9 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 | « frog/leg/lib/js_helper.dart ('k') | tests/co19/co19-leg.status » ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Dart core library. 5 // Dart core library.
6 6
7 class Math native 'Math' { 7 class Math native 'Math' {
8 /** 8 /**
9 * Base of the natural logarithms. 9 * Base of the natural logarithms.
10 */ 10 */
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 * Square root of 2. 44 * Square root of 2.
45 */ 45 */
46 static final double SQRT2 = 1.4142135623730951; 46 static final double SQRT2 = 1.4142135623730951;
47 47
48 /** 48 /**
49 * Parses a [String] representation of an [int], and returns 49 * Parses a [String] representation of an [int], and returns
50 * an [int]. Throws a [BadNumberFormatException] if [str] 50 * an [int]. Throws a [BadNumberFormatException] if [str]
51 * cannot be parsed as an [int]. 51 * cannot be parsed as an [int].
52 */ 52 */
53 static int parseInt(String str) native ''' 53 static int parseInt(String str) native '''
54 var isHex = (str.length > 2) && str[0] == '0' && 54 var match = /^\\s*[+-]?(?:(0[xX][abcdefABCDEF0-9]+)|\\d+)\\s*\$/.exec(str);
55 (str[1] == 'x' || str[1] == 'X'); 55 if (!match) \$throw(new BadNumberFormatException(str));
56 var isHex = !!match[1];
56 var ret = parseInt(str, isHex ? 16 : 10); 57 var ret = parseInt(str, isHex ? 16 : 10);
57 if (isNaN(ret)) \$throw(new BadNumberFormatException(str)); 58 if (isNaN(ret)) \$throw(new BadNumberFormatException(str));
58 return ret;''' { throw new BadNumberFormatException(""); } 59 return ret;''' { throw new BadNumberFormatException(""); }
59 60
60 /** 61 /**
61 * Parses a [String] representation of a [double], and returns 62 * Parses a [String] representation of a [double], and returns
62 * a [double]. Throws a [BadNumberFormatException] if [str] cannot 63 * a [double]. Throws a [BadNumberFormatException] if [str] cannot
63 * be parsed as a [double]. 64 * be parsed as a [double].
64 */ 65 */
65 static double parseDouble(String str) native '''var ret = parseFloat(str); 66 static double parseDouble(String str) native '''var ret = parseFloat(str);
(...skipping 30 matching lines...) Expand all
96 static double sin(num x) native; 97 static double sin(num x) native;
97 static double cos(num x) native; 98 static double cos(num x) native;
98 static double tan(num x) native; 99 static double tan(num x) native;
99 static double acos(num x) native; 100 static double acos(num x) native;
100 static double asin(num x) native; 101 static double asin(num x) native;
101 static double atan(num x) native; 102 static double atan(num x) native;
102 static double sqrt(num x) native; 103 static double sqrt(num x) native;
103 static double exp(num x) native; 104 static double exp(num x) native;
104 static double log(num x) native; 105 static double log(num x) native;
105 } 106 }
OLDNEW
« no previous file with comments | « frog/leg/lib/js_helper.dart ('k') | tests/co19/co19-leg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698