per wiki , Double-precision binary floating-point has Exponents
range from −1022 to +1023 because exponents of −1023 (all 0s) and +1024 (all 1s) are reserved for special numbers.
is it possible to get these special numbers with NumPy or other package in Python
These special numbers are Inf
and NaN
:
Infinity
Infinity is represented with an exponent of all 1s and a mantissa of all 0s. 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. 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's are represented by a bit pattern with an exponent of all 1s and a non-zero mantissa. There are two categories of NaN: QNaN (Quiet NaN) and SNaN (Signalling NaN).
You can use them with np.inf
and np.nan
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.