flopscope.numpy.finfo
flopscope.numpy.finfo(dtype)
Machine limits for floating point types.
Parameters
- dtype:float, dtype, or instance
Kind of floating point or complex floating point data-type about which to get information.
See also
- iinfo The equivalent for integer data types.
- we.flops.spacing The distance between a value and the nearest adjacent number
- we.flops.nextafter The next floating point value after x1 towards x2
Notes
For developers of NumPy: do not instantiate this at the module level.
The initial calculation of these parameters is expensive and negatively
impacts import times. These objects are cached, so calling finfo()
repeatedly inside your functions is not a problem.
Note that smallest_normal is not actually the smallest positive
representable value in a NumPy floating point type. As in the IEEE-754
standard [1]_, NumPy floating point types make use of subnormal numbers to
fill the gap between 0 and smallest_normal. However, subnormal numbers
may have significantly reduced precision [2]_.
This function can also be used for complex data types as well. If used, the output will be the same as the corresponding real float type (e.g. flops.finfo(flops.csingle) is the same as flops.finfo(flops.single)). However, the output is true for the real and imaginary components.
References
1
IEEE Standard for Floating-Point Arithmetic, IEEE Std 754-2008,
pp.1-70, 2008, https://doi.org/10.1109/IEEESTD.2008.46109352
Wikipedia, "Denormal Numbers",
https://en.wikipedia.org/wiki/Denormal_numberExamples
>>> import flopscope.numpy as fnp
>>> flops.finfo(flops.float64).dtype
dtype('float64')
>>> flops.finfo(flops.complex64).dtype
dtype('float32')