We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

How to roundoff the digits in c# ?

Varshini
Varshini asked
on
Medium Priority
359 Views
Last Modified: 2012-05-11
i have to roundoff the numbers to next 5 and next 10

95.46 should be 95.45
95.44 should be 95.45

95.47 should be 95.50
95.49 should be 95.50

95.21 should be 95.20
95.22 should be 95.25

95.19 should be 95.20
Comment
Watch Question

Author

Commented:
using c#
Project manager
CERTIFIED EXPERT
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
i you have to values only between 1 and 100 then you can try:-

Format((Math.Round((val1 + 0.01) * 20) / 20), "0.00")

Open in new window

here val1 is the value you have to round
the above code will work correctly for rounding all decimal nos upto 2 decimal places.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.