PDA

View Full Version : String to float?



filthy_freak_
6th May 2014, 10:59
Any way I can convert a string to float?

One of my floating points gets too long so I need to resize it.

Best I can come up with is to convert to string, resize, then back to float.

However I'm having trouble finding a way to convert from string back to float.

Does anyone have a method for this?

RobsoN
6th May 2014, 11:08
If you haven't got libcod, you may try this:



strToFloat(str)
{
setCvar("temp",str);
return GetCvarFloat("temp");
}

filthy_freak_
6th May 2014, 11:18
If you haven't got libcod, you may try this:



strToFloat(str)
{
setCvar("temp",str);
return GetCvarFloat("temp");
}

Thanks, working perfectly. Such an odd way to do it yet so simple.

BTW Yes i'm using libcod.

RobsoN
6th May 2014, 11:30
So you simply can do it by calling an function stringToFloat(str)

more info at: http://znation.nl/cod4script/

filthy_freak_
6th May 2014, 11:34
So you simply can do it by calling an function stringToFloat(str)

more info at: http://znation.nl/cod4script/

O.O no idea how I missed that.