If you always want it at the thousandths, you could say:
<%
function roundUp(n)
if clng(n*10000) = 10 * clng(n*1000) then
n = formatnumber(n, 3)
else
n = formatnumber(n + 0.0005, 3)
end if
roundup = n
end function
"Brent Bortnick" <brent@hitechse als.com> wrote in message
news:47db01c340 db$5ae0e710$a40 1280a@phx.gbl.. .[color=blue]
> Is there a way to make your numbers always round up. Ex:
> if the number is 0.0341 it will round to 0.035
>
> Brent[/color]
"Brent Bortnick" wrote:[color=blue]
>
> Is there a way to make your numbers always round up. Ex:
> if the number is 0.0341 it will round to 0.035[/color]
VBScript (depends on how you want to handle negative numbers):
If val*1000 <> Fix(val*1000) Then val = Fix(val*1000+1)/1000
If val*1000 <> Int(val*1000) Then val = Int(val*1000+1)/1000 http://msdn.microsoft.com/library/en...l/vsfctint.asp
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Aaron Bertrand - MVP wrote on 02 jul 2003 in
microsoft.publi c.inetserver.as p.general:
[color=blue]
> If you always want it at the thousandths, you could say:
>
> <%
> function roundUp(n)
> if clng(n*10000) = 10 * clng(n*1000) then
> n = formatnumber(n, 3)
> else
> n = formatnumber(n + 0.0005, 3)
> end if
> roundup = n
> end function
>
> response.write "<br>" & roundUp(0.0341)
> response.write "<br>" & roundUp(0.03409 )
> response.write "<br>" & roundUp(0.0340)
> response.write "<br>" & roundUp(0.0359)
>
> %>
>[/color]
Or:
function roundUp(n)
n = int(n*1000+0.99 9999)/1000
roundup = formatnumber(n, 3)
end function
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Comment