26.04.2018, 22:22
(
Последний раз редактировалось Deekaay; 28.04.2018 в 06:22.
)
Hello guys, i've got a little problem here:
I have some data stored in my database with a column containing a float, which should be the quantity of the item (0.1 min).
The problem is: when i try to subtract, let's say 0.1 from 10.0 from that float in-game, and transfer it into a new container, if i fetch the mysql data from SAMP, the game will tell me i have 9.8 and 0.1, which is 9.9 together.
The weirdest thing:
If i access my mysql database and look in it, the floats will clearly show as 9.9 and 0.1, which is 10.0 the right value that should come out in-game.
The whole system is working, inserting data, updating it, creating and deleting rows, this issue comes out only when i subtract 0.1 from 10.0 (example) but not when i subtract 0.2 from 10.0.
quant = The float in the database
quantity = The float i define to transfer
oQuantity = quant - quantity
Saving
Showing
This is what comes out when i print the value of "quantity" in both %f and %.1f
Transfer drug > QUANTITY: 0.100000 DOTONEF: 0.1
I have some data stored in my database with a column containing a float, which should be the quantity of the item (0.1 min).
The problem is: when i try to subtract, let's say 0.1 from 10.0 from that float in-game, and transfer it into a new container, if i fetch the mysql data from SAMP, the game will tell me i have 9.8 and 0.1, which is 9.9 together.
The weirdest thing:
If i access my mysql database and look in it, the floats will clearly show as 9.9 and 0.1, which is 10.0 the right value that should come out in-game.
The whole system is working, inserting data, updating it, creating and deleting rows, this issue comes out only when i subtract 0.1 from 10.0 (example) but not when i subtract 0.2 from 10.0.
quant = The float in the database
quantity = The float i define to transfer
oQuantity = quant - quantity
Saving
Код:
new Float:oQuantity = (quant - quantity); if(quantity == quant) { mysql_format(handlesql, query, sizeof(query), "DELETE FROM drugs WHERE ID = %d LIMIT 1", did); mysql_query(handlesql, query); } else { mysql_format(handlesql, query, sizeof(query), "UPDATE drugs SET Quantity = %.1f WHERE ID = %d", oQuantity, did); mysql_query(handlesql, query); }
Код:
case 1..3: { format(drugmessage, sizeof(drugmessage), "{EEA823}[{FFFFFF}%d{EEA823}]{FFFFFF} Small Bag | %s | %0.1f/28.0%s", zipquant, drug, DrugInfo[drugid][dQuantity],dose); SCM(playerid,COLOR_WHITE,drugmessage); }
Transfer drug > QUANTITY: 0.100000 DOTONEF: 0.1