简体   繁体   English

如何转换显示格式(科学记数为双精度)

[英]How to Convert The Display Format (Scientific notation to Double)

How to convert the scientific Notation in to Double.. 如何将科学计数法转换为Double ..
Please kindly refer the image For your reference 请参考图片供您参考

在此处输入图片说明

on the header column i want to display the original "-" or "+" value i want to display not scientific notation how can i do this? 在标题列上,我想显示原始的“-”或“ +”值,但我不想显示科学记数法,我该怎么做?
Coding Part 编码部分

    private void clearAndLoadTree(AccountDetails account, TreeListNode parentNode)
    {
        treeDetails.Nodes.Clear();
        treeDetails.ClearNodes();
        populateTree(account, parentNode);
        treeDetails.ExpandAll();
    }

    private double populateTree(AccountDetails account, TreeListNode parentNode)
    {
        ArrayList al = new ArrayList();
        TreeListNode currentNode = addNode(account, parentNode);
        AccountDetails[] children = account.children;
        double lcValue = account.lcValue;
        if (children != null)
        {
            foreach (AccountDetails subAccount in children)
            {
                    lcValue += populateTree(subAccount, currentNode);
            }
        }

        currentNode.SetValue("lcValue", lcValue);
        return lcValue;
    }

    private TreeListNode addNode(AccountDetails account, TreeListNode parentNode)
    {
        TreeListNode node = treeAccount.AppendNode(null, parentNode);
        ******
        return node;
    }

This will do it. 这样就可以了。

Double.Parse("-1.668E-04", NumberStyles.Float, CultureInfo.InvariantCulture);

Edit 编辑

sorry misunderstod you a little there. 抱歉,在那儿误会了你。 The above does not work on larger numbers so then you need to do this instead. 上面的方法不适用于较大的数字,因此您需要这样做。

var s = Double.Parse("-9.09494701772928E-13", NumberStyles.Float,CultureInfo.InvariantCulture);
var b = s.ToString("F50").TrimEnd("0".ToCharArray());

or 要么

string c = s.ToString("F50").TrimEnd('0')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM