12,406,649 members (59,024 online)
Rate this:
See more:
I want to round the decimal value like this
if 5.50 => 5
if 5.51 => 6 ..
I want if the decimal value after point getter than .50 then the value increment by 1.
I used Math.Round() function, but it's round after .49 decimal value..
Posted 21-Feb-13 0:31am

Rate this:

## Solution 3

Use a custom rounding system:

public int Round(double value)
{
double decimalpoints = Math.Abs(value - Math.Floor(value));
if (decimalpoints > 0.5)
return (int)Math.Round(value);
else
return (int)Math.Floor(value);
}

Hope this helps.
Jayanta Chatterjee 21-Feb-13 6:50am

Thanks a lotttttttttttt Sir..
Rate this:

## Solution 4

public int myRound(double val)
{
return (int)Math.Floor(val + .49);
}
I don't like "magic numbers" so you might want to define a const double and swap it for the 0.49
v2
Jayanta Chatterjee 21-Feb-13 6:55am

I think This is more efficient then previous answers...
Thanks Sir....
Thanks a Lottttttttttt...:-)
Rate this:

## Solution 1

basic and simple way , you can convert decimal (5.50) to int (5) and you can check for 5.50-5 greater or lower than .50 if bigger then apply your algorithim..but i dont know any other function does that automaticly.
Jayanta Chatterjee 21-Feb-13 6:44am

how to get after point(.) values?
boogac 21-Feb-13 6:47am

decimal yourDecimal=5.50;
int temp = (int)yourDecimal;//or Convert.toInt32(..) 5.50 will be 5
decimal pointAfterDecimal= yourDecimal-(decimal)temp;
Rate this:

## Solution 2

try,
String.Format("{0: 0}", _decimal_value);

hopes this work for you.
v2

Top Experts
Last 24hrsThis month
 OriginalGriff 270 Karthik Bangalore 204 Richard MacCutchan 180 BillWoodruff 85 Afzaal Ahmad Zeeshan 75
 OriginalGriff 7,957 Karthik Bangalore 3,531 ppolymorphe 3,400 Richard MacCutchan 2,612 F-ES Sitecore 2,300

Web02 | 2.8.160730.1 | Last Updated 21 Feb 2013