Page 1 of 1

Constant Strings can't convert to int(or double) properly

PostPosted: Sat Nov 11, 2017 10:57 pm
by ZippeyKeys12
Code: Select allExpand view
const x="12";
int y=x.ToInt();
console.printf("%d",y);
Prints 0
Code: Select allExpand view
int y="12".ToInt();
console.printf("%d",y);
Prints 0
But...
Code: Select allExpand view
String x="12";
int y=x.ToInt();
console.printf("%d",y);
Prints 12
I don't think this is intended, and while running ToInt() on a literal is pointless, some may want to run it on a constant.

EDIT: Also happens with ToDouble()

Re: Constant Strings can't convert to int(or double) properl

PostPosted: Sun Jan 21, 2018 10:11 am
by Graf Zahl
The compiler really accepts this? I am not surprised that it fails. To call a function you need to take the address of a variable. For a constant that's not possible at the moment.

Re: Constant Strings can't convert to int(or double) properl

PostPosted: Sun Jun 03, 2018 11:33 am
by Graf Zahl
Moved to "on hold" because I really do not have any good idea how to deal with this.