returning float in callremotefunction
#1

So I'm returning float values by CallRemoteFunction, but it returns more something else than it's supposed to causing it to spawn me at a wrong position.


I have this at the end:

return SpawnPos[cpID][Coord];

When it should return:
2271.7598,-1658.9670,14.7538

it actually returns:
2271.759765,-1658.967041,14.753800

How do I fix this?
Reply
#2

EDIT: Yes, I clearly need more sleep. Vince has the right idea.
Reply
#3

Float values are not absolute values and I don't see anything wrong with those return values either. They have more significant digits, but so what?
Reply
#4

Quote:

causing it to spawn me at a wrong position

I doubt that, since the returned values only differ 0.0001m max. If you must round them off you can use format() with the %.04f specifier.

pawn Код:
new Float:exact = 1.1266666666;
new rounded[32];
format(rounded, sizeof(rounded), "%.04f", exact);

// rounded = 1.1267
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)