Rounding functions

M

Mike

Hi, I have a list of numbers I would like to round to different
decimals based on the value of the number. I would use a select case
to do this but I am not sure how to round to set values. For example:

number is between 1-2, round to nearest 0.01
number is between 2-3, round to nearest 0.02
number is between 3-4, round to nearest 0.05
number is between 4-6, round to nearest 0.1

would I need to strip the decimal from the whole number and perform
functions on the decimal part or are there any ready made functions
that can do this?

Thanks,

Mike
 
A

AMDRIT

Remember that solution was intended for VB5/6 and made use of Doubles. You
should change all the doubles to decimal to retain precision in .Net.
 
G

Guest

Can't you use the Round method of the Decimal class, like:

myRoundedDecimal = Decimal.Round (mydecimal, NoOfSignificantDigits)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top