By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,219 Members | 2,361 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,219 IT Pros & Developers. It's quick & easy.

Rounding functions

P: n/a
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?



Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies

P: n/a
found the answer:

Nov 21 '05 #2

P: n/a
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.
"Mike" <my***> wrote in message
found the answer:

Nov 21 '05 #3

P: n/a
thanks :-)

Nov 21 '05 #4

P: n/a
Can't you use the Round method of the Decimal class, like:

myRoundedDecimal = Decimal.Round (mydecimal, NoOfSignificantDigits)
Dennis in Houston
"Mike" wrote:
thanks :-)

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.