Chromium Code Reviews| Index: frog/lib/math.dart |
| diff --git a/frog/lib/math.dart b/frog/lib/math.dart |
| index 46c3beaae1fc4d8e2bfd03e0cdeec6c141a51012..9e53624642af4707dbf01ae796d2bf850b25df0e 100644 |
| --- a/frog/lib/math.dart |
| +++ b/frog/lib/math.dart |
| @@ -50,7 +50,10 @@ class Math native 'Math' { |
| * an [int]. Throws a [BadNumberFormatException] if [str] |
| * cannot be parsed as an [int]. |
| */ |
| - static int parseInt(String str) native '''var ret = parseInt(str); |
| + static int parseInt(String str) native ''' |
| + var isHex = (str.length > 2) && str[0] == '0' && |
|
kasperl
2012/03/02 13:34:10
Do you need to trim first?
floitsch
2012/03/02 17:00:29
Using a regexp now.
|
| + (str[1] == 'x' || str[1] == 'X'); |
| + var ret = parseInt(str, isHex ? 16 : 10); |
| if (isNaN(ret)) \$throw(new BadNumberFormatException(str)); |
| return ret;''' { throw new BadNumberFormatException(""); } |