标签: scientific-notation

科学 ofstream 中的指数只有 2 位数

因此,根据 cplusplus.com,当您通过以下方式将输出流的格式标志设置为科学记数法时

of.setf(ios::scientific)

您应该在指数中看到 3 位加号和一个符号。但是,我的输出中似乎只有 2 个。有任何想法吗?使用 GCC 4.0.1 在 Mac OS 上编译。

这是我正在使用的实际代码:

of.setf(ios::scientific);
of.precision(6);
for (int i=0;i<dims[0];++i) {
    for (int j=0;j<dims[1];++j) {
    of << setw(15) << data[i*dims[1]+j];                    
    }
    of << endl;
}
Run Code Online (Sandbox Code Playgroud)

和一个示例输出行:

   1.015037e+00   1.015037e+00   1.395640e-06  -1.119544e-06  -8.333264e-07
Run Code Online (Sandbox Code Playgroud)

谢谢

c++ scientific-notation

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

这个值是什么意味着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++ 中将科学记数法转换为十进制

我希望能够在我的代码中的所有情况下以十进制输出而不是科学输出。

如果我有 122041e+08 那么我希望它显示为 122041000

如果我有 4.6342571e+06 那么我希望它显示为 4634257.1

... 等等。

使用我的代码,4.6342571e+06 的输出是 4634257.100000

void conversion(double counts)
{
  std::ostringstream ss;
  ss << std::fixed << counts;
  std::cout << ss.str() << " MeV";
}
Run Code Online (Sandbox Code Playgroud)

有人可以向我解释为什么它会在末尾添加 0 以及是否可以删除它们。

c++ scientific-notation decimal

5
推荐指数
2
解决办法
9871
查看次数

Fibonacci序列 - 查找位数 - JavaScript

所以,我已经成功地编写了Fibonacci序列来创建一个array带有数字序列的序列,但我需要知道该数字的长度(多少位数)500th.

我已经尝试了下面的代码,但它找到了科学记数法的长度(22位数),而不是应该返回的正确的105.

有关如何将科学记数法转换为实际整数的任何想法?

var fiblength = function fiblength(nth) {
    var temparr = [0,1];
    for(var i = 2; i<=nth; i++){
        var prev = temparr[temparr.length-2],
            cur = temparr[temparr.length-1],
            next = prev + cur;
            temparr.push(next);
    }
    var final = temparr[temparr.length-1].toString().length;
    console.log(temparr[temparr.length-1]);
    return final;
};
a = fiblength(500);
console.log(a);
Run Code Online (Sandbox Code Playgroud)

javascript scientific-notation fibonacci notation

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

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
查看次数

MongoDB 将数字转换为科学计数法的字符串

我想获得完整的数字 a String,但"1490650000000"它返回科学记数法"1.49065e+12"

这是我尝试转换它的方法:

{$substr: ["$myNumber", 0, -1]};
Run Code Online (Sandbox Code Playgroud)

有什么想法如何预防吗?

注意: 我使用的是v3.6,无法升级使用$toString(感谢mlab)。

scientific-notation tostring mongodb mongodb-query aggregation-framework

5
推荐指数
2
解决办法
3214
查看次数

如何在轴上显示 x10(上标数字)而不是 1e(数字)?

我知道如何在 matplotlib 中使用科学记数法表示轴末尾的唯一方法是

plt.ticklabel_format(style='sci', axis='y', scilimits=(0,0))

但这将使用 1e 而不是 x10。在下面的示例代码中,它显示 1e6,但我想要 x10 的 6 次方,x10superscript6(x10^6,其中 6 小且没有 ^)。有没有办法做到这一点?

编辑:我不想在轴上的每个刻度上使用科学记数法(恕我直言,这看起来不太好),只在最后,如示例所示,但仅将 1e6 部分更改为 x10superscript6。

我还不能包含图像。

谢谢

import numpy as np
import matplotlib.pyplot as plt
plt.figure()
x = np.linspace(0,1000)
y = x**2
plt.plot(x,y)
plt.ticklabel_format(style='sci', axis='y', scilimits=(0,0))
plt.show()
Run Code Online (Sandbox Code Playgroud)

python scientific-notation matplotlib python-3.x

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

在jquery的setInterval()和setTimeout()中使用hex

我正在创建一个脚本来检查服务器是否已连接或已经消失.在查看其他人是如何完成它的时候,我意识到有些人在函数内部使用了十六进制.例如 setInterval(l,6E4)

另一个例子

setTimeout(function(){d(window.checknet.config.checkURL)},window.checknet.config.checkInterval)}a=a||{};a.checkURL=a.checkURL||window.location.href;a.checkInterval=a.checkInterval||5E3;a.warnMsg=a.msg||"No Internet connection detected, disabled features will be re-enabled when a connection is detected. ";
Run Code Online (Sandbox Code Playgroud)

这是使用十六进制 a.checkInterval=a.checkInterval||5E3;

为什么使用十六进制而不是普通的十进制数字?

math jquery scientific-notation

4
推荐指数
1
解决办法
2705
查看次数