标签: scientific-notation

如何在Matlab中得到科学记数的指数

当数字非常小时,Matlab会自动将它们格式化为科学记数法.

例:

A = rand(3) / 10000000000000000;

A =

  1.0e-016 *

    0.6340    0.1077    0.6477
    0.3012    0.7984    0.0551
    0.5830    0.8751    0.9386
Run Code Online (Sandbox Code Playgroud)

是否有一些内置函数返回指数?像这样的东西:getExponent(A) = -16

我知道这是一个愚蠢的问题,但我需要检查数百个矩阵,我似乎无法弄明白.

谢谢您的帮助.

matlab scientific-notation matrix exponent

6
推荐指数
1
解决办法
1万
查看次数

使用ggplot从科学记数法转换为十进制

我正在尝试ggplot使用以下命令绘制一些测试数据(在本文末尾显示):

options(scipen=20)    
ggplot(testData,aes(x=Group.1, y=x), format(scientific=FALSE)) + 
scale_x_discrete(name="Test", formatter=comma) + geom_bar()
Run Code Online (Sandbox Code Playgroud)

该图生成得足够好,但x轴是科学记数法(如在测试数据中),我将如何以十进制显示它?(如命令所示,我已经尝试过scipen选项和各种格式化程序选项 - 如本网站其他帖子所示)

我的测试数据:

> str(testData)
'data.frame':   5 obs. of  2 variables:
$ Group.1: Factor w/ 5 levels "(1.3e+03,1.5e+03]",..: 1 2 3 4 5
$ x      : num  80000 94000 86000 112000 98000

> testData
            Group.1      x
1 (1.3e+03,1.5e+03]  80000
2 (1.5e+03,1.7e+03]  94000
3 (1.7e+03,1.9e+03]  86000
4 (1.9e+03,2.1e+03] 112000
5 (2.1e+03,2.3e+03]  98000

> dput(testData)
structure(list(Group.1 = structure(1:5, .Label = c("(1.3e+03,1.5e+03]", 
"(1.5e+03,1.7e+03]", "(1.7e+03,1.9e+03]", "(1.9e+03,2.1e+03]", 
"(2.1e+03,2.3e+03]"), class = "factor"), x …
Run Code Online (Sandbox Code Playgroud)

r scientific-notation ggplot2

6
推荐指数
1
解决办法
5300
查看次数

如何在C中表示科学记数法

如何用一定数量的有效数字表示C中的极大或极小数字.例如,如果我想在1.54334E-34上进行计算,我该怎么做呢.此外,这适用于OpenCL代码吗?

c scientific-notation scientific-computing opencl

6
推荐指数
2
解决办法
4万
查看次数

将科学记数法转换为十进制 - 蟒蛇

如何将科学记数法转换为浮点数?这是我想要避免的一个例子:

Python 2.7.3 (default, Apr 14 2012, 08:58:41) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a=[78.40816326530613, 245068094.16326532]
>>> print a[0]/a[1]
3.19944395589e-07
>>> print float(a[0]/a[1])
3.19944395589e-07
>>> print float(a[0])/float(a[1])
3.19944395589e-07
Run Code Online (Sandbox Code Playgroud)

python scientific-notation floating-point-conversion

6
推荐指数
2
解决办法
2万
查看次数

使用相同指数打印2个双打的最佳方法

如何以科学记数法最好地打印2个浮点数但具有相同的指数?例如:我想打印这样的数字:

 1.234e-6 
11.234e-6
Run Code Online (Sandbox Code Playgroud)

我想要一些功能来自动检测最佳指数 - 较小的数字始终从第一个十进制数字开始,较大的数字打印它必须具有相同的指数.例如:0.1和100将打印

   1.000e-1
1000.000e-1
Run Code Online (Sandbox Code Playgroud)

但即使我明确要求String.format("%2.3e",11.234e-6)我得到2个小数位 1.123e-5

java string double scientific-notation

6
推荐指数
1
解决办法
106
查看次数

Python numpy科学记数法限制小数

我试图减少一些计算后得到的小数位数.print()我的问题出现在哪里看起来像这样:

print("Mean resistivity: {res} Ohm m".format(res=np.mean(resistivity)))
Run Code Online (Sandbox Code Playgroud)

它输出这个:

Mean resistivity: 1.6628449915450776e-08 Ohm m
Run Code Online (Sandbox Code Playgroud)

现在我想减少打印到3的小数位数.我尝试用字符串格式化,如下所示:

print("Mean resistivity: {res:.3f} Ohm m".format(res=np.mean(resistivity)))
Run Code Online (Sandbox Code Playgroud)

但是,此代码打印:

Mean resistivity: 0.000 Ohm m
Run Code Online (Sandbox Code Playgroud)

我真正想要的是这个:

Mean resistivity: 1.663e-8 Ohm m
Run Code Online (Sandbox Code Playgroud)

如何将格式化res为仅显示为科学记数法,但只有3位小数?

python numpy scientific-notation string-formatting

6
推荐指数
1
解决办法
591
查看次数

这个值是什么意味着excel中的1.845E-07?

我正在使用互操作服务从C#中读取excel表.我的工作表的单元格值为0.00.但是当我在C#代码中检查该单元格的值时运行时我得到"1.845E-07"这个值.当我签入excel表格时,右键单击该单元格,说格式单元格我在样本部分得到"1.845E-07"值.如何获得准确的价值?请帮我.代码很大,所以我不能在这里提供.那条线是:

if (Convert.ToString(((Excel.Range)worksheet.Cells[iRowindex, colIndex_q10]).Value2) != string.Empty)
{
    drRow[dtSourceEXLData.Columns[constants.Floor]] = ((Excel.Range)worksheet.Cells[iRowindex, colIndex_q10]).Value2.ToString();
}
Run Code Online (Sandbox Code Playgroud)

与日期单元格"39448"相同的问题.这意味着什么?请帮助....

excel scientific-notation

5
推荐指数
1
解决办法
22万
查看次数

C中的E表示法

我正在阅读C编程 - 一种现代的方法,我偶然发现了关于电子符号的部分.我很难理解它们.

请使用以下代码:

printf("%12.5e", 30.253);
Run Code Online (Sandbox Code Playgroud)

这导致以下输出:

3.02530e+01
Run Code Online (Sandbox Code Playgroud)

谁能解释一下这是如何工作的?数字12在这里表示什么?

c scientific-notation

5
推荐指数
1
解决办法
1万
查看次数

Python中科学记数法中的指数数字

在 Python 中,科学记数法总是给我 2 位数的指数:

print('%17.8E\n' % 0.0665745511651039)
6.65745512E-02
Run Code Online (Sandbox Code Playgroud)

但是,我非常希望有 3 个数字,例如:

6.65745512E-002
Run Code Online (Sandbox Code Playgroud)

我们可以使用 Python 中的内置配置/函数来做到这一点吗?

我知道我的问题与以下问题基本相同:Python - number of digits in exponent,但这个问题是 4 年前提出的,我不想调用这样的函数一千次。我希望现在应该有更好的解决方案。

python scientific-notation exponent

5
推荐指数
1
解决办法
5402
查看次数

在悬停工具散景中禁用科学记数法

似乎有很多关于如何在 x 和 y 轴上显示的数字上禁用散景中的科学记数法的答案。但是如何为悬停工具禁用它呢?

interactive scientific-notation hover bokeh

5
推荐指数
1
解决办法
1367
查看次数