mscproj
asked on
Ceil function
Is there any ceil function on asp, and even pass the parameter of up to which decimal numbers.
E.g.
33.2 -> 34
33.8 -> 34
If pass parameter up to 1 decimal
33.24 -> 33.3
33.28 -> 33.3
If pass parameter up to 2 decimal
33.242 -> 33.25
33.246 -> 33.25
E.g.
33.2 -> 34
33.8 -> 34
If pass parameter up to 1 decimal
33.24 -> 33.3
33.28 -> 33.3
If pass parameter up to 2 decimal
33.242 -> 33.25
33.246 -> 33.25
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try "Round"
;->
;->
VBScript:
Function CeilNum(i, n)
Dim k
k = CDbl("1e" & n)
CeilNum = CInt(i * k) / k
End Function
Function CeilNum(i, n)
Dim k
k = CDbl("1e" & n)
CeilNum = CInt(i * k) / k
End Function
JavaScript:
function ceilNum(i, n)
{
var k = parseFloat("1e" + n);
return Math.ceil(i*k)/k;
}
jkunal, round(33.2) = 33!
function ceilNum(i, n)
{
var k = parseFloat("1e" + n);
return Math.ceil(i*k)/k;
}
jkunal, round(33.2) = 33!
Yuri:
ceil(222.2223) ???
xabi
ceil(222.2223) ???
xabi
ASKER
Thanks!
function myceil(num)
sTmp = cstr(num)
iPosPoint = instr(1,sTmp,".")
myceil=cint(mid(STmp,1,iPo sPoint-1)) +1
end function
sTmp = cstr(num)
iPosPoint = instr(1,sTmp,".")
myceil=cint(mid(STmp,1,iPo
end function
<%@ Language=VBScript %>
<%
function ceil(number)
if isNumeric(number) then
sTmp = cstr(number)
iPosPoint = instr(1,sTmp,".")
ceil = number
if iPosPoint > 0 then
iNumDec = len(sTmp) - iPosPoint
if iNumDec > 0 then
sTmp = left(sTmp,iPosPoint-1) & right(sTmp, iNumDec - 1)
sTmp = cstr(clng(stmp + 1))
sTmp = left(sTmp,len(sTmp)-(iNumD
ceil = csng(sTmp)
else
ceil = cint(left(sTmp,iPosPoint-1
end if
end if
else
ceil = 0
end if
end function
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
Response.Write(ceil("222.2
%>
<P> </P>
</BODY>
</HTML>