Exemplo n.º 1
0
    /// <summary>
    /// 通过字符串初始化
    /// </summary>
    public void initByStr(string str)
    {
        if (str.isEmpty())
        {
            setEmpty();
            return;
        }

        int re = 0;

        for (int i = str.Length - 1; i >= 0; --i)
        {
            if (StringUtils.isCharIsNumber(str[i]))
            {
                re = i + 1;
                break;
            }
        }

        //没有末尾
        if (re == str.Length)
        {
            rank  = 0;
            value = double.Parse(str);
        }
        else
        {
            rank  = BigFloatRankConfig.getRankByStr(str.Substring(re));
            value = double.Parse(str.Substring(0, re));
        }

        refresh();
    }
Exemplo n.º 2
0
    /// <summary>
    /// 获取每阶文字
    /// </summary>
    public static string getRankStr(int rank)
    {
        BigFloatRankConfig config = get(rank);

        if (config != null)
        {
            return(config.str);
        }

        return("rank(" + rank + ")");
    }
Exemplo n.º 3
0
    /// <summary>
    /// 转化数字显示
    /// </summary>
    public string toNumberString()
    {
        if (_numberStrDirty)
        {
            _numberStrDirty = false;

            if (Global.bigFloatWei == 0)
            {
                Ctrl.throwError("未初始化BigFloat配置");
            }

            if (rank == 0)
            {
                _numberStr = StringUtils.floorStrD2(value);
            }
            else
            {
                _numberStr = StringUtils.floorStrD2(value) + BigFloatRankConfig.getRankStr(rank);
            }
        }

        return(_numberStr);
    }