Question
#1

DELETED:

Edit: Being more specific.

pawn Код:
new Float: X, Float: Y, Float: Z;

GetPlayerPos(playerid, X, Y, Z);
Okay let's say X is 1499.890984, Y is 38.796445, and Z is not used.
I don't want the last 4 digits, I just want X to be 1499.89 and Y to be 38.79.
Basically rounding to the hundredth place in a decimal (float).
How do I do that?

Edit2: Solved.
pawn Код:
new Float: X, Float: Y, Float: Z;

GetPlayerPos(playerid, X, Y, Z);

X = (floatround((X * 100)) / 100);
Y = (floatround((X * 100)) / 100);
Reply
#2

Quote:

new Float:fMyHugeFloat = 9995499.24;
new Float:fMyFloatPI = 3.1415926535;

Fill that out with your details.
Reply
#3

No not like that, convert
Float: 7890.764596 to
Float: 7890.764000 or/and 7890.760000

Like make the last 3 digits 0 or last 4 digits 0
Reply
#4

So you mean yuo don't want random number at the last and just want 0000 at the last?

Quote:

This forum requires that you wait 120 seconds between posts. Please try again in 14 seconds.

Reply
#5

pawn Код:
new Float: X, Float: Y, Float: Z;

GetPlayerPos(playerid, X, Y, Z);
Okay let's say X is 1499.890984, Y is 38.796445, and Z is not used.
I don't want the last 4 digits, I just want X to be 1499.89 and Y to be 38.79.
Basically rounding to the hundredth place in a decimal (float).
How do I do that?
Reply
#6

https://sampwiki.blast.hk/wiki/Floatround
Reply
#7

That converts a float to an integer...
Please read [This Post] carefully.

Edit: Solved.

Question:
pawn Код:
new Float: X, Float: Y, Float: Z;

GetPlayerPos(playerid, X, Y, Z);
Okay let's say X is 1499.890984, Y is 38.796445, and Z is not used.
I don't want the last 4 digits, I just want X to be 1499.89 and Y to be 38.79.
Basically rounding to the hundredth place in a decimal (float).
How do I do that?

Answer
pawn Код:
new Float: X, Float: Y, Float: Z;

GetPlayerPos(playerid, X, Y, Z);

X = (floatround((X * 100)) / 100);
Y = (floatround((X * 100)) / 100);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)