---> Need help with Float.
#1

Hey,
Lets say I have this float:
Код:
65.6895282826
And I want to turn this float into:
Код:
65.68
... How can I do this?


Thanks.
Reply
#2

What what I understand there might be a better way to do this but if you trying to save to a file do this.

new line[128];
format(line, sizeof(line), "%0.2f %0.2f %0.2f %0.2f", float1, float2, float3, float4);

That will round out to 2 decimal places.

Now if your not saving and want to round it try this

new roundvalue[32];

format(roundvalue, sizeof(roundvalue), "0.2f", floatvalue);
floatvalue = floatstr(roundvalue);

Mind you floats are not accurate so it probably won't round as expected.
Reply
#3

Awsome,works great.
Thanks.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)