Rounding help...
#2

Quote:
Originally Posted by lesley
How to round a number that the result's last cipher is 5 or 0,

could it be something like that? :
Код:
new rounded, num;
num = 47;
rounded = (num / 5) * 5;
in my example, 'rounded' should be 45..
Here's the newbish way to do it. I'm sure someone will come along and find a better way to do it sooner or later.
pawn Код:
new num1, num2;
num1 = 4;
num2 = 7;
if(num2 < 5) { num2 = 0; } else if(num2 >= 5) { num2 = 5; }
Reply


Messages In This Thread
Rounding help... - by lesley - 13.03.2009, 21:07
Re: Rounding help... - by Pyrokid - 13.03.2009, 21:49
Re: Rounding help... - by lesley - 13.03.2009, 23:11
Re: Rounding help... - by Nero_3D - 13.03.2009, 23:21
Re: Rounding help... - by lesley - 14.03.2009, 00:05
Re: Rounding help... - by maij - 14.03.2009, 06:46
Re: Rounding help... - by lesley - 14.03.2009, 09:27
Re: Rounding help... - by Nero_3D - 14.03.2009, 13:19

Forum Jump:


Users browsing this thread: 1 Guest(s)