Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

C#: Rounding decimal numbers

Posted on 2012-03-18
5
501 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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…
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…

766 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