开发者

Rounding Decimal Indian Rupees C#

I wan开发者_JS百科t to round off one decimal variable (ex Rs. 5.65) with 2 rules:

  1. if the part after decimal (.65 in the example) in greater that 49, add 1 to the part before decimal.(Make it 6)
  2. If the part after decimal is less that 49(ex: 2.45) remove the part after decimal(Ex: Make it 2.00)

Please suggest a solution.

EDIT Can anyone tell me how to achieve the same using TSQL and CrystalReport ???


Look at Math.Round(decimal, MidPointRounding), it should do what you need.


Ok.. when in doubt look at the System.Math object. In your case what you want is

Math.Round(SomeDecimal);


iif(5.655 % Math.Round(5.6549, 2) > 0.49, Math.Ceiling(5.6549), Math.Floor(5.6549));

iif(5.655 % Math.Round(5.655, 2) > 0.49, Math.Ceiling(5.655), Math.Floor(5.655));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜