julia数据使用科学计数法并保留指定位数的有效数字

julia运行一个循环,设定每100步输出一些信息到REPL,想输出6位有效数字,小数点后位数可以用科学计数法,目前代码如下

println("Step = ", Int16(iterStep/100), ", po-V = ", round(residuals[iterStep, 1], digits = 6), ", po-C = ", round(residuals[iterStep, 2], digits = 6), ", ch-V = ", round(residuals[iterStep, 3], digits = 6), ", ch-C = ", round(residuals[iterStep, 4], digits = 6))

在面板中显示内容如下

Step = 1, po-V = 0.015198, po-C = 3.1e-5, ch-V = 0.029447, ch-C = 0.000121
Step = 2, po-V = 0.011468, po-C = 3.3e-5, ch-V = 0.017572, ch-C = 0.000101
Step = 3, po-V = 0.006982, po-C = 2.9e-5, ch-V = 0.013219, ch-C = 9.0e-5

只到小数点后六位,并没有六位有效数字。请问我应该用什么方法或者函数实现?

using Printf,然后用@printf,就可以像C语言一样用科学计数法 %m.ne。

1赞

京ICP备17009874号-2