round up to nearst 20th

# Thread: round up to nearst 20th

1. Member
Join Date
Dec 1969
Posts
40

## round up to nearst 20th

how would i round up to nearst 20th?<BR><BR>here is my faild attept:<BR><BR>&#060;%<BR><BR>Response.Write FIX(19)<BR><BR>%&#062;<BR><BR>I search all over. I am trying to round any number to the nearest 20th.<BR><BR>Examples: 17 would round to 20, 20 would round to 20, 21 would round to 40, Thanks alot.<BR><BR><BR><BR>

2. Member
Join Date
Dec 1969
Posts
40

## RE: round up to nearst 20th

How can I round 1.1 and make it 2 ?

3. Senior Member
Join Date
Dec 1969
Posts
5,955

## You're trying to do a lot of...

...rounding, aren&#039;t you? :-)<BR><BR>Well, let&#039;s have a look at the Microsoft documentation on their website. Fix seems to be a start. The only thing is, that it doesn&#039;t work for numbers that are already integers, so you&#039;d have to program something yourself:<BR><BR>Function MyFix(dNumber)<BR>&nbsp;&nbsp;&nbsp;&nbsp;If Fix(dNumber) = dNumber Then &#039; This is already rounded<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;MyFix = dNumber<BR>&nbsp;&nbsp;&nbsp;&nbsp;Else<BR>&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyFix = Fix(dNumber) + 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;End If<BR>End Function<BR><BR>Now to your other problem. That should be straightforward. Again, you need to program something yourself.<BR><BR>Function Nearest20(nNumber)<BR>&nbsp;&nbsp;&nbsp;&nbsp;Near est20 = Fix(nNumber / 20) * 20<BR>End Function<BR><BR>I didn&#039;t test either of the functions, so please make sure you do that before you use them in your program.<BR><BR>Oliver.

4. Member
Join Date
Dec 1969
Posts
40

## RE: You're trying to do a lot of...

Thanks Oliver Kinne, I didn&#039;t know what I was doing. I was looking at the math functions, and couldn&#039;t find any for this.<BR><BR>What you have will work.

#### Posting Permissions

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