Converting a string to a float? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Converting a string to a float? (
/showthread.php?tid=65114)
Converting a string to a float? -
NovaParadox - 10.02.2009
Alright, Im trying to load a float from a MySQL table. The MySQL table has the value. When I try to load it by using strval(Field); it returns the value without anything beyond the decimal point. Example, getting the value 1800.125 from the MySQL table, gives that value 1800.0000. Can someone tell me a solution to this?
Re: Converting a string to a float? -
ICECOLDKILLAK8 - 10.02.2009
%.0f will limit it down to 1 decimal point
Re: Converting a string to a float? -
NovaParadox - 10.02.2009
Trying to assign it to a variable, that has nothing to do with what i'm trying to do. float(strval(Field)); will not work either
Re: Converting a string to a float? -
ICECOLDKILLAK8 - 10.02.2009
format(string, sizeof(string), "%.0f", w/e string variable);
new variable = strval(string);
Re: Converting a string to a float? -
NovaParadox - 10.02.2009
Wrong again, I did some searching, the answer is floatstr(string[]);
Re: Converting a string to a float? -
ICECOLDKILLAK8 - 10.02.2009
Quote:
Originally Posted by NovaParadox
Wrong again, I did some searching, the answer is floatstr(string[]);
|
Thats the way i do it and it works fine for me, Why bother posting here before searching anyway?
Re: Converting a string to a float? -
NovaParadox - 10.02.2009
I added a word that wasnt needed and it made the search return no results