09.12.2011, 18:44
How do I round a number to the nearest hundreth?
number = floatround(number*100.0)/100.0;
dcmd_stats(playerid, params[]) { #pragma unused params new msg[128]; new Float:kd = floatround(pInfo[playerid][kills] / pInfo[playerid][deaths]*100.0)/100.0; format(msg, sizeof(msg), "Kills: %i | Deaths: %i | Ratio: %f", pInfo[playerid][kills], pInfo[playerid][deaths], kd); SCM(playerid, COLOR_RED, "_________STATS_________"); SCM(playerid, COLOR_RED, msg); return 1; }
Kills: 635 | Deaths: 86 | Ratio: 7.000000
new Float:kd = floatround((pInfo[playerid][kills] / pInfo[playerid][deaths])*100.0)/100.0;
new Float:kd = pInfo[playerid][kills] / pInfo[playerid][deaths];
format(msg, sizeof(msg), "Kills: %i | Deaths: %i | Ratio: %0.2f", pInfo[playerid][kills], pInfo[playerid][deaths], kd);
new Float:kd = floatdiv(pInfo[playerid][kills], pInfo[playerid][deaths]);