sea026(沸点海岭) 
老兄,那这个问题怎么解决呢?
就是要解决我的计算结果四舍五入的问题
而且是保留两位小数(按照我们的习惯四舍五入)

解决方案 »

  1.   

    使用decimal数据类型,此类型是C#中精度最高的类型--------------------------
    学习一下。
      

  2.   

    SaSBYa(置身珠海,置身学习,置身奋斗)的方法不错。数据类型用decimal转换,具体用C#我就不是很清楚,MS SQL、Delphi可以指定小数位。
      

  3.   

    试一下,Math.Round((float/decimal)yourdata,2)
      

  4.   

    不要误导。
    Decimal.Round 方法请参见
    Decimal 结构 | Decimal 成员 | System 命名空间 | Floor | Truncate | Decimal 成员(Visual J# 语法) | C++ 托管扩展编程 
    要求
    平台: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 系列, .NET Framework 精简版 - Windows CE .NET, 公共语言基础结构 (CLI) 标准
    语言
    C#C++JScriptVisual Basic全部显示
    将 Decimal 值舍入到指定的小数位数。[Visual Basic]
    Public Shared Function Round( _
       ByVal d As Decimal, _
       ByVal decimals As Integer _
    ) As Decimal[C#]
    public static decimal Round(
       decimal d,
       int decimals
    );[C++]
    public: static Decimal Round(
       Decimal d,
       int decimals
    );[JScript]
    public static function Round(
       d : Decimal,
       decimals : int
    ) : Decimal;参数

    要舍入的 Decimal 值。 
    decimals 
    指定数字要舍入到的小数位数的值,该值范围是从 0 到 28。 
    返回值
    Decimal 数等于舍入到 d 小数位数的 decimals。异常
    异常类型 条件 
    ArgumentOutOfRangeException decimals 不是 0 到 28 之间的值。 备注
    当 d 正好位于两个舍入值的正中间时,结果将是最右边小数位中有偶数位的舍入值。例如,当舍入为两位小数时,值 2.345 变成 2.34,而值 2.355 变成 2.36。此过程称为向偶舍入或就近舍入。要求
    平台: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 系列, .NET Framework 精简版 - Windows CE .NET, 公共语言基础结构 (CLI) 标准请参见
    Decimal 结构 | Decimal 成员 | System 命名空间 | Floor | Truncate | Decimal 成员(Visual J# 语法) | C++ 托管扩展编程 
    --------------------------------------------------------------------------------发送有关此主题的意见 © 2001-2002 Microsoft Corporation。保留所有权利。 
      

  5.   

    private string MyRound(string data, int DesLength)//我们的四舍五入(非国际化的就近原则)
    {
    decimal d = Convert.ToDecimal(data);
    int dd; 
    d *= (decimal)Math.Pow(10, DesLength);
    d += 0.5m;
    dd = (int)d;
    return Convert.ToString(dd/Math.Pow(10, DesLength));  }--------------------------
    学习一下。
      

  6.   

    SaSBYa(置身珠海,置身学习,置身奋斗) 
    的方法在计算的时候我就是这么用的,关键是最后截取两位的时候要四舍五入啊
    就是在这个时候碰到这样的问题啊
    比如
    1111111.525
    你如何能截取成1111111.53呢?我的那个方法能够处理绝大多数的数字
    现在就发现少数几个数字没发解决,如前所述。
      

  7.   

    我之所以用double是因为处理的数字可能要很大