VB Script ceiling function (rounding up)? 
Author Message
 VB Script ceiling function (rounding up)?

Does VB Script have a ceiling function, or a function that will round a
floating point number up to the nearest whole number?  Please advise.
Thanks.

Russ Ehmke > microsoft.public.scripting.VBScript > 04/13/99

=====



Sat, 29 Sep 2001 03:00:00 GMT  
 VB Script ceiling function (rounding up)?
No, but implementing your own is not too hard.  One thing you could do is
add 0.5 and then call Round.  However, you have to make sure that you check
to see if the number is already a whole number -- otherwise, this will
sometimes round it up to the next whole number which is not what you want.

Something like

Function Ceil(x)
    If Round(x) = x Then
        Ceil = x
    Else
        Ceil = Round(x + 0.5)
    End If
End Function

Eric


Quote:
> Does VB Script have a ceiling function, or a function that will round a
> floating point number up to the nearest whole number?  Please advise.
> Thanks.

> Russ Ehmke > microsoft.public.scripting.vbscript > 04/13/99

> =====



Sun, 30 Sep 2001 03:00:00 GMT  
 VB Script ceiling function (rounding up)?
Yep.  I couldn't find anything in the documentation, but you're right - it's
pretty easy to implement.  Thanks.

Russ Ehmke

--



Quote:
> No, but implementing your own is not too hard.  One thing you could do is
> add 0.5 and then call Round.  However, you have to make sure that you
check
> to see if the number is already a whole number -- otherwise, this will
> sometimes round it up to the next whole number which is not what you want.

> Something like

> Function Ceil(x)
>     If Round(x) = x Then
>         Ceil = x
>     Else
>         Ceil = Round(x + 0.5)
>     End If
> End Function

> Eric



> > Does VB Script have a ceiling function, or a function that will round a
> > floating point number up to the nearest whole number?  Please advise.
> > Thanks.

> > Russ Ehmke > microsoft.public.scripting.vbscript > 04/13/99

> > =====



Tue, 02 Oct 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ceiling function in vbscript/asp?

2. CEILING/FLOOR Function

3. Floor and Ceiling functions

4. problems with mySQL "floor/ceiling" function

5. CINT function -- vb rounding question

6. VB Round function and Access database

7. VB - Round Function

8. Round or Fix Function

9. Round function

10. The Round() Function in VBScript

11. round() function problem

12. about round() function

 

 
Powered by phpBB® Forum Software