简体   繁体   English

是否可以使用NumPy或Python中的某些其他软件包来保留特殊精度的双精度二进制浮点数

[英]Is it possible to get reserved special numbers of double-precision binary floating-point with NumPy or some other package in Python

per wiki , Double-precision binary floating-point has Exponents 每个Wiki ,双精度二进制浮点具有指数

range from −1022 to +1023 because exponents of −1023 (all 0s) and +1024 (all 1s) are reserved for special numbers. 范围从−1022到+1023,因为−1023(全0)和+1024(全1)的指数保留给特殊数字。

is it possible to get these special numbers with NumPy or other package in Python 是否有可能通过NumPy或其他Python包获得这些特殊数字

These special numbers are Inf and NaN : 这些特殊数字是InfNaN

Infinity

Infinity is represented with an exponent of all 1s and a mantissa of all 0s. 无穷大用全1的指数和全0的尾数表示。 Depending on the sign bit, it can be a positive infinity(+∞) or negative infinity (-∞). 根据符号位的不同,它可以是正无穷大(+∞)或负无穷大(-∞)。 The infinity is used in case of the saturation on maximum representable number so that the computation could continue. 在最大可表示数达到饱和时使用无穷大,以便继续计算。

NaN

The value NaN (Not a Number) is used to represent a value that does not represent a real number. 值NaN(非数字)用于表示不表示实数的值。 They are used in computations that generate undefined results so that with NaN the operations are defined for it to let the computations continue. 它们用于产生不确定结果的计算中,因此使用NaN可以为其定义操作,以使计算继续进行。 NaN's are represented by a bit pattern with an exponent of all 1s and a non-zero mantissa. NaN由具有全为1的指数和非零尾数的位模式表示。 There are two categories of NaN: QNaN (Quiet NaN) and SNaN (Signalling NaN). NaN有两类:QNaN(安静的NaN)和SNaN(信令NaN)。

You can use them with np.inf and np.nan . 您可以将它们与np.infnp.nan

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM