Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String.toInt() raises IllegalArgument if the string starts with a zero #1006

Open
sanderginn opened this issue Dec 1, 2016 · 1 comment
Open

Comments

@sanderginn
Copy link

sanderginn commented Dec 1, 2016

Not sure if this intended behaviour.

toInt("059215102311135031132");
|plugin://rascal/src/org/rascalmpl/library/String.rsc|(9689,431,<414,0>,<434,52>): IllegalArgument()
        at *** somewhere ***(|plugin://rascal/src/org/rascalmpl/library/String.rsc|(9689,431,<414,0>,<434,52>))
        at toInt(|prompt:///|(6,23,<1,6>,<1,29>))


rascal>toInt("59215102311135031132");
int: 59215102311135031132
@mahills
Copy link
Member

mahills commented Dec 1, 2016

The error message could definitely be better, but this occurs because the number is given in octal (starts with a 0) but contains illegal digits (the 9). For instance, this works fine:

rascal>toInt("057215102311135031132");
int: 851642288897798746

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants