zoukankan      html  css  js  c++  java
  • 用C#写 四舍五入函数(函数版)

    适用范围:长整型long(-9223272036854775808 ~  +9223272036854775808)
            //BY: bit.Aipeli 2005-11-07 23:27:23

            
    private double Round(double v,int x)
            
    {
                
    int i;
                long
     IValue=1;
                
    double DValue=1;
            
                
    for (i=1;i<=x;i++)
                
    {
                    IValue
    =IValue*10;
                    DValue
    =DValue/10;
                }

                
    long Int=(long)Decimal.Round(Convert.ToDecimal(v*IValue),0);
                
    double Key=(double)(v/DValue)-Int;
                
    double Dou=(double)Int/IValue;

                
    if (Key>=0.5)
                
    {
                    Dou
    +=DValue;
                }

                
    return Dou;
            }

    本代码在:Windows 2003 && Microsoft Visual Studio .NET 2003 通过
  • 相关阅读:
    能直接调用析构函数,不能直接调用构造函数
    第二章、IP协议详解
    第一章、TCP协议详解
    STL
    容器
    7、jQuery选择器及绑定方法
    6、JQuery语法
    5、DOM 定时器 和 JQuery 选择器
    4、DOM之正则表达式
    3、JS函数与DOM事件
  • 原文地址:https://www.cnblogs.com/aipeli/p/271057.html
Copyright © 2011-2022 走看看