MySQL -- Gallons - 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)
+--- Thread: MySQL -- Gallons (
/showthread.php?tid=521500)
MySQL -- Gallons -
yoran765 - 23.06.2014
Hello!
Stumbled across a problem again, let me explain.
I am storing decimal numbers inside a MySQL Database. They are automatically set as : 15.3. I load this into one of my vehicle variables that is assigned as a float. (Float:vGallons) Lowering them would be simple wouldn't it?
PHP код:
Vehicle[vid][vGallons]-=0.1;
This does lower them but for some odd reason it sets itself as 15.199999 instead of 15.2. I've already tried to set my Gallons in my database to a varchar but no luck.
EDIT : It might be because they're assigned as a float. (The variable) but yeah.
Re: MySQL -- Gallons -
Vince - 23.06.2014
If it bothers you that much, format it as "%.1f". This will truncate the fractional part to a single character.
Re: MySQL -- Gallons -
yoran765 - 23.06.2014
Mind giving me an example?
EDIT : Nevermind, but formating vGallons to %.1f is not working...