简体   繁体   English

如何以科学计数法格式化 PowerApps 中的文本输出?

[英]How to format text output in PowerApps in scientific notation?

在此处输入图像描述

In the image above, I have a text label that is dependent on a radio.在上图中,我有一个依赖于收音机的文本标签。 If a button is selected, a multiplication is done on a value from a collection, and then the output is sent to a text label.如果选择了一个按钮,则会对集合中的值进行乘法运算,然后将输出发送到文本标签。

After the multiplication, the number I have is 71015997100, but I need to display it like 7.101e+10乘法后,我得到的数字是 71015997100,但我需要像 7.101e+10 这样显示

Can someone guide me on how to do this?有人可以指导我如何做到这一点吗?

The desired output is: 7.101e+10 or 7.101E+10期望的输出是:7.101e+10 或 7.101E+10

You can use an expression like the one below to format the number in exponential notation:您可以使用如下所示的表达式以指数表示法格式化数字:

With(
  { v: 71015997100 },
  With(
    { p10: RoundDown(Log(v),0) },
    $"{Text(v/10^p10,"0.000")}e+{p10}"))

If you may have values smaller than 1 (in which case you would need a negative power of 10), you can use something like the following:如果您的值可能小于 1(在这种情况下您需要 10 的负幂),您可以使用如下内容:

With(
  { v:.005697 },
  With(
    { p10: RoundDown(Log(v),0) - If(v<1, 1, 0) },
    $"{Text(v/10^p10,"0.000")}e{If(v<1,"-","+")}{Abs(p10)}"))

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

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