9.00000000e-01 是什么数字?
What kind of number 9.00000000e-01 is?
我声明了一个 x
变量并用 np.arange(-1, 1, 0.1)
填充了它。 print(x)
方法给了我这样的东西:
[ -1.00000000e+00 -9.00000000e-01 -8.00000000e-01 -7.00000000e-01
-6.00000000e-01 -5.00000000e-01 -4.00000000e-01 -3.00000000e-01
-2.00000000e-01 -1.00000000e-01 -2.22044605e-16 1.00000000e-01
2.00000000e-01 3.00000000e-01 4.00000000e-01 5.00000000e-01
6.00000000e-01 7.00000000e-01 8.00000000e-01 9.00000000e-01]
这些是什么数字?如何将它们转换为 float
类型?提前谢谢你。
这些是使用 scientific notation 编写的浮点值。所以,9e-1
是9×10-1或0.9.
数字9.00000000e-01
已经是一个浮点数。
写成scientific notation相当于9 * 10**-1
或0.9
。
>>> import numpy as np
>>> x = np.arange(-1,1,0.1)
>>> print(x)
[ -1.00000000e+00 -9.00000000e-01 -8.00000000e-01 -7.00000000e-01
-6.00000000e-01 -5.00000000e-01 -4.00000000e-01 -3.00000000e-01
-2.00000000e-01 -1.00000000e-01 -2.22044605e-16 1.00000000e-01
2.00000000e-01 3.00000000e-01 4.00000000e-01 5.00000000e-01
6.00000000e-01 7.00000000e-01 8.00000000e-01 9.00000000e-01]
>>> type(x[0])
<type 'numpy.float64'>
>>> print(x.tolist())
[-1.0, -0.9, -0.8, -0.7000000000000001, -0.6000000000000001, -0.5000000000000001, -0.40000000000000013, -0.30000000000000016, -0.20000000000000018, -0.1000000000000002, -2.220446049250313e-16, 0.09999999999999964, 0.19999999999999973, 0.2999999999999998, 0.3999999999999997, 0.49999999999999956, 0.5999999999999996, 0.6999999999999997, 0.7999999999999996, 0.8999999999999995]
>>> type(x.tolist()[0])
<type 'float'>
类型最初是 numpy float64。
我声明了一个 x
变量并用 np.arange(-1, 1, 0.1)
填充了它。 print(x)
方法给了我这样的东西:
[ -1.00000000e+00 -9.00000000e-01 -8.00000000e-01 -7.00000000e-01
-6.00000000e-01 -5.00000000e-01 -4.00000000e-01 -3.00000000e-01
-2.00000000e-01 -1.00000000e-01 -2.22044605e-16 1.00000000e-01
2.00000000e-01 3.00000000e-01 4.00000000e-01 5.00000000e-01
6.00000000e-01 7.00000000e-01 8.00000000e-01 9.00000000e-01]
这些是什么数字?如何将它们转换为 float
类型?提前谢谢你。
这些是使用 scientific notation 编写的浮点值。所以,9e-1
是9×10-1或0.9.
数字9.00000000e-01
已经是一个浮点数。
写成scientific notation相当于9 * 10**-1
或0.9
。
>>> import numpy as np
>>> x = np.arange(-1,1,0.1)
>>> print(x)
[ -1.00000000e+00 -9.00000000e-01 -8.00000000e-01 -7.00000000e-01
-6.00000000e-01 -5.00000000e-01 -4.00000000e-01 -3.00000000e-01
-2.00000000e-01 -1.00000000e-01 -2.22044605e-16 1.00000000e-01
2.00000000e-01 3.00000000e-01 4.00000000e-01 5.00000000e-01
6.00000000e-01 7.00000000e-01 8.00000000e-01 9.00000000e-01]
>>> type(x[0])
<type 'numpy.float64'>
>>> print(x.tolist())
[-1.0, -0.9, -0.8, -0.7000000000000001, -0.6000000000000001, -0.5000000000000001, -0.40000000000000013, -0.30000000000000016, -0.20000000000000018, -0.1000000000000002, -2.220446049250313e-16, 0.09999999999999964, 0.19999999999999973, 0.2999999999999998, 0.3999999999999997, 0.49999999999999956, 0.5999999999999996, 0.6999999999999997, 0.7999999999999996, 0.8999999999999995]
>>> type(x.tolist()[0])
<type 'float'>
类型最初是 numpy float64。