round up

1. Member
Join Date
Dec 1969
Posts
89

## round up

Hi everyone,<BR>there&#039;s a function that round up a number? I.E. if I&#039;ve 4.01 it rounds to 5...<BR><BR>Nick

2. Senior Member
Join Date
Dec 1969
Posts
2,958

## Did you

Check the ASPFAQ&#039;s link above? Under math.

3. Member
Join Date
Dec 1969
Posts
89

## it speaks about round but not round up

thank you, but there forum in aspfaq speaks to round, not to round up always to the bigger integer...<BR><BR>Nick

4. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## That should be easy

Number = clng(Number + .5)<BR><BR><BR>

5. Senior Member
Join Date
Dec 1969
Posts
2,958

## Gee

I think that&#039;s what the FAQ said.

6. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## Well not really

I THINK it has LOT extra....never really did look at it<BR><BR><BR>Yep just read it.....it is diff....not something a newbie will be to "hone"<BR><BR><BR>

7. Senior Member
Join Date
Dec 1969
Posts
2,958

## Ok I sit corrected. Sorry newbie <eop>

.

8. Senior Member
Join Date
Dec 1969
Posts
96,118

If the number happens to *already* be an integer, then doing<BR><BR>CLNG( num + 0.5 )<BR><BR>will give you the *NEXT* integer! Right? 7 + 0.5 is 7.5, yes? And 7.5 rounded to the nearest integer is 8, yes?<BR><BR>You would think you could do <BR><BR>CLNG( num + 0.4999999999 )<BR><BR>but at how many 9&#039;s do you cut that off? If you put in too few, then a number very close to an integer will not round up. If you put in too many, you exceed the limit of precision of double numbers and, effectively, end up adding 0.5 again.<BR><BR>The *BEST* way to ensure an accurate ROUNDUP of a number is to right a small function:<BR><BR>&#060;%<BR>Function RoundUp( ByVal num )<BR>&nbsp; &nbsp; If num = Int(num) Then RoundUp = num Else RoundUp = Int(num) + 1<BR>End Function<BR>%&#062;<BR><BR>

9. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## Yep

Did not think of that.<BR><BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•