Using vbscript How can I round up to the next int
Don

Re: How to round up. by Ray

Ray
Thu Dec 04 08:10:49 CST 2003

This might work.

Function RoundUp(someNum)
If CLng(someNum) = CDbl(someNum) Then
RoundUp = someNum
Else
RoundUp = Int(someNum) + 1
End If
End Function

Ray at work


"Don Grover" <spamfree@assoft.com.au> wrote in message
news:Oy7OgOluDHA.1788@tk2msftngp13.phx.gbl...
> Using vbscript How can I round up to the next int
> Don
>
>



Re: How to round up. by Alex

Alex
Sun Dec 07 20:50:44 CST 2003

Ray,

It definitely works _exactly_ like Math.ceil. There's an easier way though.
I used the same way you showed until I ran across the fact that Math.ceil(x)
= - Math.floor(-x). Since VBScript's Int() is identical to a floor, rounding
up can be done simply with:

-Int(-x)

Slick, huh? VBScript is almost never that compact...


Ray at <%=sLocation%> wrote:
> This might work.
>
> Function RoundUp(someNum)
> If CLng(someNum) = CDbl(someNum) Then
> RoundUp = someNum
> Else
> RoundUp = Int(someNum) + 1
> End If
> End Function
>
> Ray at work
>
>
> "Don Grover" <spamfree@assoft.com.au> wrote in message
> news:Oy7OgOluDHA.1788@tk2msftngp13.phx.gbl...
>> Using vbscript How can I round up to the next int
>> Don



Re: How to round up. by Ray

Ray
Sun Dec 07 21:21:43 CST 2003

That is very cool!

Ray at home

"Alex K. Angelopoulos [Server MVP]" <aka-at-mvps-dot-org> wrote in message
news:e$xuUYTvDHA.2308@TK2MSFTNGP09.phx.gbl...
> Ray,
>
> It definitely works _exactly_ like Math.ceil. There's an easier way
though.
> I used the same way you showed until I ran across the fact that
Math.ceil(x)
> = - Math.floor(-x). Since VBScript's Int() is identical to a floor,
rounding
> up can be done simply with:
>
> -Int(-x)
>
> Slick, huh? VBScript is almost never that compact...