SA-MP Forums Archive
Question - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Question (/showthread.php?tid=362972)



Question - Sniper Kitty - 26.07.2012

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);



Re: Question - Genuine - 26.07.2012

Quote:

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

Fill that out with your details.


Re: Question - Sniper Kitty - 26.07.2012

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


Re: Question - McCurdy - 26.07.2012

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.




Re: Question - Sniper Kitty - 26.07.2012

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?


Re: Question - newbienoob - 26.07.2012

https://sampwiki.blast.hk/wiki/Floatround


Re: Question - Sniper Kitty - 26.07.2012

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);