Solved

C#: Rounding decimal numbers

Posted on 2012-03-18
5
503 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
[X]
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
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

690 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