Solved

C#: Rounding decimal numbers

Posted on 2012-03-18
5
498 Views
Last Modified: 2012-05-18
Calculation results have to be rounded up to the nearest 0.05

thanks
0
Comment
Question by:quasar_ee
5 Comments
 
LVL 20

Assisted Solution

by:a_b
a_b earned 250 total points
Comment Utility
0
 
LVL 17

Assisted Solution

by:sonawanekiran
sonawanekiran earned 250 total points
Comment Utility
0
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 0 total points
Comment Utility
var result = 105.06;
result = Math.Round(Math.Round(result/0.05, 0)*0.05, 2);

Open in new window

0
 
LVL 16

Expert Comment

by:Easwaran Paramasivam
Comment Utility
Below method could be used.

Decimal.Round(YourValue, 2),
0
 
LVL 16

Expert Comment

by:Easwaran Paramasivam
Comment Utility
String round = YourValue.ToString("#0.00");
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now