Rounding off integer. - 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: Rounding off integer. (
/showthread.php?tid=604241)
Rounding off integer. -
AroseKhanNiazi - 02.04.2016
How can I round of an integer to 3 decimal places if it has 6

.
Re: Rounding off integer. -
SyS - 02.04.2016
hmm maybe there will be a function in pawn like setprecise of iomanip library in c++
Re: Rounding off integer. -
introzen - 02.04.2016
Quote:
Originally Posted by AroseKhanNiazi
How can I round of an integer to 3 decimal places if it has 6  .
|
An integer cannot have decimals. You're talking about a float and in that case you would have to use regex and take the decimal you want, round it off and add everything up to a float again.
Re: Rounding off integer. -
AroseKhanNiazi - 04.04.2016
Sorry my bad 3 whole number place; anyway isn't this code right to get mili seconds?
pawn Код:
pMili[playerid]=GetTickCount(); // this is when race started..
pMili[playerid]=(((GetTickCount()-pMili[playerid])-(1000*pSec[playerid]))-((1000*60)*pMin[playerid]));
should give me 3 digits and should work but it gives me some random numbers mostly more than 3.