finfo#

ivy.finfo(type, /)[source]#

Machine limits for floating-point data types.

Parameters:

type (Union[Dtype, str, Array, NativeArray]) – the kind of floating-point data-type about which to get information.

Return type:

None

Returns:

ret – an object having the following attributes:

  • bits: int

number of bits occupied by the floating-point data type.

  • eps: float

difference between 1.0 and the next smallest representable floating-point number larger than 1.0 according to the IEEE-754 standard.

  • max: float

largest representable number.

  • min: float

smallest representable number.

  • smallest_normal: float

smallest positive floating-point number with full precision.

This function conforms to the Array API Standard. This docstring is an extension of the docstring in the standard.

Examples

With ivy.Dtype input:

>>> y = ivy.finfo(ivy.float32)
>>> print(y)
finfo(resolution=1e-06, min=-3.4028235e+38, max=3.4028235e+38, dtype=float32)

With str input:

>>> y = ivy.finfo('float32')
>>> print(y)
finfo(resolution=1e-06, min=-3.4028235e+38, max=3.4028235e+38, dtype=float32)

With ivy.Array input:

>>> x = ivy.array([1.3,2.1,3.4], dtype=ivy.float64)
>>> print(ivy.finfo(x))
finfo(resolution=1e-15, min=-1.7976931348623157e+308,     max=1.7976931348623157e+308, dtype=float64)
>>> x = ivy.array([0.7,8.4,3.14], dtype=ivy.float16)
>>> print(ivy.finfo(x))
finfo(resolution=0.001, min=-6.55040e+04, max=6.55040e+04, dtype=float16)

With ivy.Container input:

>>> c = ivy.Container(x=ivy.array([-9.5,1.8,-8.9], dtype=ivy.float16),
...                   y=ivy.array([7.6,8.1,1.6], dtype=ivy.float64))
>>> print(ivy.finfo(c))
{
    x: finfo(resolution=0.001, min=-6.55040e+04, max=6.55040e+04, dtype=float16),
    y: finfo(resolution=1e-15, min=-1.7976931348623157e+308,             max=1.7976931348623157e+308, dtype=float64)
}
Array.finfo(self, /)[source]#

Array instance method variant of ivy.finfo.

Parameters:

self (Array) – input array.

Return type:

None

Returns:

ret – An instance of the Finfo class, containing information about the floating point data type of the input array.

Example

>>> x = ivy.array([0.7,8.4,3.14], dtype=ivy.float32)
>>> print(x.finfo())
finfo(resolution=1e-06, min=-3.4028235e+38, max=3.4028235e+38, dtype=float32)
Container.finfo(self, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

ivy.Container instance method variant of ivy.finfo.

Parameters:

self (Container) – input container with leaves to inquire information about.

Return type:

Container

Returns:

ret – container of the same structure as self, with each element as a finfo object for the corresponding dtype of leave in`self`.

Examples

>>> c = ivy.Container(x=ivy.array([-9.5,1.8,-8.9], dtype=ivy.float16),
...                   y=ivy.array([7.6,8.1,1.6], dtype=ivy.float64))
>>> print(c.finfo())
{
    x: finfo(resolution=0.001, min=-6.55040e+04, max=6.55040e+04,                    dtype=float16),
    y: finfo(resolution=1e-15, min=-1.7976931348623157e+308,                 max=1.7976931348623157e+308, dtype=float64)
}