Solved

C#: Rounding decimal numbers

Posted on 2012-03-18
5
500 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
ID: 37736259
0
 
LVL 17

Assisted Solution

by:sonawanekiran
sonawanekiran earned 250 total points
ID: 37736362
0
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 0 total points
ID: 37736557
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
ID: 37737232
Below method could be used.

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

Expert Comment

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

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

786 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