什么样的号码9.00000000e-01是?

时间:2015-01-05 12:54:01

标签: python numpy scipy

我已声明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类型?提前谢谢。

3 个答案:

答案 0 :(得分:9)

已经的数字9.00000000e-01 是一个浮点数。

scientific notation写的,相当于9 * 10**-10.9

答案 1 :(得分:1)

这些是使用scientific notation编写的浮点值。因此,9e-1 9×10 -1 0.9

答案 2 :(得分:1)

>>> 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。