```
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.

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..

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..

Use a custom rounding system:

Hope this helps.

```
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.

Comments

Thanks a lotttttttttttt Sir..

```
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.49v2

Comments

I think This is more efficient then previous answers...

Thanks Sir....

Thanks a Lottttttttttt...:-)

Thanks Sir....

Thanks a Lottttttttttt...:-)

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.

Comments

how to get after point(.) values?

decimal yourDecimal=5.50;

int temp = (int)yourDecimal;//or Convert.toInt32(..) 5.50 will be 5

decimal pointAfterDecimal= yourDecimal-(decimal)temp;

int temp = (int)yourDecimal;//or Convert.toInt32(..) 5.50 will be 5

decimal pointAfterDecimal= yourDecimal-(decimal)temp;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject,
503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada
+1 416-849-8900 x 100