Esempio n. 1
0
    /// <summary>
    /// 通过int创建
    /// </summary>
    public static BigFloatData createByDouble(double value)
    {
        BigFloatData re = new BigFloatData();

        re.initByDouble(value);
        return(re);
    }
Esempio n. 2
0
    /// <summary>
    /// 比大小(b1<b2返回-1),b1==b2返回0,b1>b2返回1
    /// </summary>
    public static int compare(BigFloatData b1, double value)
    {
        int i1 = MathUtils.doubleCompare(b1.value, 0);
        int i2 = MathUtils.doubleCompare(value, 0);

        if (i1 != i2)
        {
            return(MathUtils.intCompare(i1, i2));
        }

        if (i1 == 0)
        {
            return(0);
        }

        if (Math.Abs(value) < Global.bigFloatWeiValue)
        {
            int rankRe = MathUtils.intCompare(b1.rank, 0);

            if (rankRe != 0)
            {
                return(i1 > 0 ? rankRe : -rankRe);
            }

            return(MathUtils.doubleCompare(b1.value, value));
        }
        else
        {
            BigFloatData tempData = b1._tempData;

            if (tempData == null)
            {
                tempData = b1._tempData = new BigFloatData();
            }

            tempData.initByDouble(value);
            return(compare(b1, tempData));
        }
    }