gpt4 book ai didi

actionscript-3 - 弹性/mxml : How to display a Number in scientific notation in TextInput box?

转载 作者:行者123 更新时间:2023-12-02 22:35:09 25 4
gpt4 key购买 nike

在我的 Flex 应用程序中,我有一个 TextInput 框,用户可以在其中输入数字。它以字符串形式出现,然后通过 NumberFormatter 传递。然后结果显示在 TextInput 框中。这适用于小数字。

大数字有问题。例如,如果用户输入 100e30(这是 1x10^32 的科学记数法),TextInput 显示:

100000000000000000000000000000000

当我真正想要展示的是

1.0E32

这就是它在 Flash Builder 内部的显示(和存储)方式,例如,使用调试器查看时。

AS3/mxml中有没有简单的例程可以输出科学计数法到TextInput控件?

最佳答案

var n:Number = 10000000000;
trace(n.toExponential(1));

输出:

1.0e+10

将其设置为文本输入:

textInput.text = n.toExponential(1);

关于actionscript-3 - 弹性/mxml : How to display a Number in scientific notation in TextInput box?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11564283/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com