Calculate the exact number for the given percentage in c#

Vasanth
 
on Jan 30, 2013 01:31 AM
2255 Views

Hi

I need to deduct the amount for the given percentage but i am having small difference in the calculatiion

I do the following

  int input = 6065;

  int result = input * 60/100;

The result i got is 3657.  But the actual result is 3657.6 and i need to round up so i need to get

3658.

Can any one suggest me the solution for this.

Download FREE API for Word, Excel and PDF in ASP.Net: Download
Mustafa
 
on Jan 30, 2013 01:43 AM
on Jan 30, 2013 01:44 AM

Hi Vasanth,

You can try this

decimal input = 6096;
decimal result = decimal.Round((input * 60)/100);

This will work as you want