SA-MP Forums Archive
Round off a number? - 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: Round off a number? (/showthread.php?tid=301076)



Round off a number? + 1 question - RelaxCafe - 03.12.2011

Is there a function? Or may I say how to make one to round off a number.
For example: if the value of a variable is 23.5, how to round it to 24?

Will this work?

new r1=strfind(altitude, ".", true);
if(strval(r1+1 >5))altitude++;//will change 23.5 to 24 - it it isn't more than 5.. the number will stay the same..
strdel(altitude, r1, 5);// assuming there will not be more that five integers after the decimal
//other stuff...


Am not sure if I am suppose to use strval.. I don't think it will work.. because strval may find the value of the length: r1+1( +1 = number after decimal).. Is there anyother fuction i can use to get the number i want..


That 1 question: How to find info from a file inside a specific folder.. I mean to loop every file in a folder without knowing the files' names?


Re: Round off a number? - Joe Staff - 03.12.2011

floatround(number,roundmethod);