在Python中获取不正确的最大值和最小值作为指数值

问题描述

对于代码脚本中给出的那种值,我使用max()和np.max()得到了不正确的max和min值。我有一个数组,其中填充的值类似于这三个值。

编辑:似乎我已经冻结了大脑,我很抱歉,值是正确的。我不敢相信我在这里呆了两个小时。随时删除或标记此帖子。

import numpy as np

c = 0.0000e+00
d = 2.2141e-42
e = 9.1835e-41

max([c,d,e]) # Returns 9.1835e-41
np.max(np.array([c,e])) # Returns 9.1835e-41

min([c,e]) # Returns 0.0
np.min(np.array([c,e])) # Returns 0.0

解决方法

用十进制符号表示,而不是科学符号,结果是:

c = 0
d = 0.0000000000000000000000000000000000000000022141
e = 0.000000000000000000000000000000000000000091835

我想说c是最小的,e是最大的,这似乎也符合maxnp.max的想法。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...