That seems kind of funky. Why not use the Mod function in your
solution, which divides a number and returns the remainder? Like...
Public Function RoundNumber(dblOriginalNumber)
If dblOriginalNumber Mod 1 >= 0.5 Then
RoundNumber = Cint(dblOriginalNumber - (dblOriginalNumber Mod 1) +
1)
Else
RoundNumber = Cint(dblOriginalNumber - (dblOriginalNumber Mod 1))
End If
End Function
Just seems more reliable, and then you can use numbers with as many
decimal places as you like.
- John
> -----Original Message-----
> From: Chamindu Ruwin Munasinghe [mailto:[EMAIL PROTECTED]
> Sent: Thursday, April 29, 2004 12:21 AM
> To: '[EMAIL PROTECTED]'
> Subject: RE: [ASP] rounding integers
>
>
> Hi
> Use this ceil( number * 2) /2 . The ciel function gives
> you the nearest integer greater than the given value. since
> vbscript doesnt have that here is a workaround
>
> Public Function Ceil(dValue)
> Ceil = Int(dValue + 0.9999999999)
> End Function
>
> for this function to work make sure you dont use numbers with
> 10 decimal places.
>
> HTH
> Chamindu
>
> -----Original Message-----
> From: Moshe Tapnack
> To: asp4 (asp4)
> Sent: 4/28/2004 11:08 PM
> Subject: [ASP] rounding integers
>
> hi gang
>
> i'd like to round integers to the closest .5 or integer, ie:
> 3.4 would show: 3.5 and 3.8 would show: 4.
> i've tried with cInt and round() but as you all know, that
> doesnt do the trick.
>
> is there any built in funtion for this?
>
> thanks!
> Moshe
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
>
> ---------------------------------------------------------------------
>
> Home : http://groups.yahoo.com/group/active-server-pages
> ---------------------------------------------------------------------
> Post : [EMAIL PROTECTED]
> Subscribe : [EMAIL PROTECTED]
> Unsubscribe: [EMAIL PROTECTED]
> ---------------------------------------------------------------------
> Yahoo! Groups Links
>
>
>
>
>
>
> --------------------------------------------------------------
> -------
> Home : http://groups.yahoo.com/group/active-server-pages
> ---------------------------------------------------------------------
> Post : [EMAIL PROTECTED]
> Subscribe : [EMAIL PROTECTED]
> Unsubscribe: [EMAIL PROTECTED]
> ---------------------------------------------------------------------
> Yahoo! Groups Links
>
>
>
>
>
>
>
---------------------------------------------------------------------
Home : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
Post : [EMAIL PROTECTED]
Subscribe : [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
---------------------------------------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/active-server-pages/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/