[SOLVED] Float 'accuracy'
#1

SOLVED: See bottom.

Is there any way to fix the issue with floats where this happens:

pawn Код:
new Float:test = 0.7;
printf("%f", test);
Output: 0.699999

?

****** explained it here: https://sampforum.blast.hk/showthread.php?tid=276438
But is there really no way to 'fix' this? At least for displaying it..

SOLVED:
This function fixed it as best it can:


pawn Код:
Float:FixedFloat(Float:float)
{
    return (float + 0.0000001);
}
It displays at 0.700000, not 0.7000001, which is even better. Even if that was the case, 0.7000001 would be better than 0.69 when only wanting to display one or two decimal points.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)