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

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Constant Strings can't convert to int(or double) properly

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

by Graf Zahl » Sun Jun 03, 2018 11:33 am

Moved to "on hold" because I really do not have any good idea how to deal with this.

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

by Graf Zahl » Sun Jan 21, 2018 10:11 am

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.

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

by ZippeyKeys12 » Sat Nov 11, 2017 10:57 pm

Code: Select all

const x="12";
int y=x.ToInt();
console.printf("%d",y);
Prints 0

Code: Select all

int y="12".ToInt();
console.printf("%d",y);
Prints 0
But...

Code: Select all

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()

Top