How do I round up?

# Thread: How do I round up?

1. I have question Guest

## How do I round up?

I know there is a Round function which goes like this:<BR>Round(expression[, numDecimalPlaces])<BR>But this function returns rounded number, not rounded up or rounded down... I thought about this script:<BR>if round(x/y,0) not x/y then<BR>a = round(x/y)+1<BR>else<BR>a = x/y<BR>end if<BR><BR>Does anyone here know any shorter way?

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

## RE: How do I round up?

See if this helps<BR><BR>http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=87

3. I have question Guest

## Actualy... No...

But I got a better script now...:<BR>a = Round(x/y+0.49,0)<BR>If x/y has no digits after the decimal point, it would be rouned down, and won&#039;t change the expression x/y, and if it is bigger, it would return the x/y+1.

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

## You *almost* have it right...

It should be<BR><BR>If X &#060;&#062; Int(X) Then X = Int(X)+1<BR><BR>To see why, consider rounding 3.00001<BR><BR>With your version, 3.00001+0.49 --&#062;&#062; 3.49001 which *still* rounds to 3.0<BR><BR>Incidentally, if you think that you won&#039;t have any values such as 3.00001, then you may need to look at how floating point numbers actually work. You can *easily* get 3.00001 (well, more likely 3.0000000000001) when you do floating point arithmetic that you *think* is giving you just 3.0 as the result. It&#039;s just the nature of the beast.<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
•