[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cobalt-developers] ASP always round up



On 4 Sep 2003 at 15:22, Todd Kirk wrote:

> Hi All,
> 
> Have a need to always round up returned number values. Any ideas on how to
> achieve this with ASP on a RAQ4R?
> 
> I have looked at Round(var) but see no way to always round up to the nearest
> whole number.
> 
> .net has a function called 'ceiling' which performs what I want...anything
> like that in ASP I'm not aware of?
> 
>  
> kind regards,
>  
> Todd Kirk

Hi Todd,

This should do it:


<%
Randomize

for x=1 to 20
	' generate some random numbers between 1-100 for testing
	r = (100 * Rnd) + 1
	Response.write r & ", " & RoundUp(r) & "<BR>"
next
	

function RoundUp( num )
	If IsNumeric(num) then
		if fix(num) <> num then
			RoundUp = fix(num)+1
		else
			RoundUp = num
		end if
	end if
end function
%>

Regards

Ian
--