[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 506
  • Last Modified:

C#: Rounding decimal numbers

Calculation results have to be rounded up to the nearest 0.05

thanks
0
quasar_ee
Asked:
quasar_ee
3 Solutions
 
BuggyCoderCommented:
var result = 105.06;
result = Math.Round(Math.Round(result/0.05, 0)*0.05, 2);

Open in new window

0
 
Easwaran ParamasivamCommented:
Below method could be used.

Decimal.Round(YourValue, 2),
0
 
Easwaran ParamasivamCommented:
String round = YourValue.ToString("#0.00");
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now