Converting float to 1 decimal point
#5

pawn Код:
stock Float:ConvertFloatToOneDP(Float:value)
{
    new Float:result;
    new tempInt;
    result = value * 10.0;
    tempInt = floatround(result);
    result = float(tempInt);
    result = result / 10.0;
    result = result + 0.0000006; // Fixes floating point inaccuracy (e.g. 0.99999999)
   
    return result;
}
Perhaps there is a better method, but for me it was this or format.
Reply


Messages In This Thread
Converting float to 1 decimal point - by MP2 - 11.04.2015, 21:21
AW: Converting float to 1 decimal point - by Mencent - 11.04.2015, 21:24
Re: Converting float to 1 decimal point - by MP2 - 11.04.2015, 21:25
AW: Re: Converting float to 1 decimal point - by Nero_3D - 11.04.2015, 21:59
Re: Converting float to 1 decimal point - by MP2 - 12.04.2015, 15:42

Forum Jump:


Users browsing this thread: 1 Guest(s)