Table of Contents

Class finfo

Namespace
NumSharp
Assembly
NumSharp.dll

Machine limits for floating point types.

public sealed class finfo
Inheritance
finfo
Inherited Members

Remarks

Constructors

finfo(DType)

Create finfo for the specified dtype.

public finfo(DType dtype)

Parameters

dtype DType

A floating point dtype (a Type, NPTypeCode, dtype string or DType — all convert implicitly).

Exceptions

TypeError

dtype is null: NumPy 2.5's dtype must not be None (NumPy 2.4 deprecated a None and returned float64's limits).

ValueError

dtype is not a floating point or complex type: NumPy 2.5's data type dtype('int32') not compatible with finfo, naming the descriptor's repr in native byte order (NumPy normalizes it through result_type first; text names its own descriptor, dtype('<U3') or StringDType()). A ValueError is an ArgumentException, so code that catches the latter still catches it.

Properties

bits

Number of bits occupied by the type.

public int bits { get; }

Property Value

int

dtype

The dtype of this floating point type — NumPy's finfo.dtype (a DType descriptor, like np.finfo(np.float64).dtype). For a complex input this is the underlying REAL float dtype (float64 for complex128), matching NumPy. Being a DType it exposes kind / name / itemsize and compares structurally (info.dtype == np.float64); an NPTypeCode also converts back implicitly.

public DType dtype { get; }

Property Value

DType

eps

The difference between 1.0 and the next smallest representable float larger than 1.0.

public double eps { get; }

Property Value

double

epsneg

The difference between 1.0 and the next smallest representable float smaller than 1.0.

public double epsneg { get; }

Property Value

double

iexp

NumPy's iexp: the number of bits in the exponent field — 5 (float16), 8 (float32), 11 (float64 and complex128). The same value as nexp (NumPy keeps both names).

public int iexp { get; }

Property Value

int

Remarks

NumSharp-only for decimal: 8, the byte that holds its scale.

machep

NumPy's machep: the exponent that yields eps, eps == 2**machep — -10 (float16), -23 (float32), -52 (float64 and complex128).

public int machep { get; }

Property Value

int

Remarks

NumSharp-only for decimal: -28, a power of TEN (eps == 10**-28): decimal is a base-10 format, which its eps and minexp already follow.

max

The largest representable number.

public double max { get; }

Property Value

double

maxexp

The smallest positive power of the base (2) that causes overflow.

public int maxexp { get; }

Property Value

int

min

The smallest representable number (typically -max).

public double min { get; }

Property Value

double

minexp

The most negative power of the base (2) consistent with there being no leading 0s in the mantissa — NumPy's minexp, so 2**minexp == smallest_normal: -14 (float16), -126 (float32), -1022 (float64 and complex128). NumSharp reported -125 / -1021 (C's FLT_MIN_EXP convention) before API-parity batch 7.

public int minexp { get; }

Property Value

int

negep

NumPy's negep: the exponent that yields epsneg, epsneg == 2**negep — -11 (float16), -24 (float32), -53 (float64 and complex128).

public int negep { get; }

Property Value

int

Remarks

NumSharp-only for decimal: -28, a power of ten like machep.

nexp

NumPy's nexp: the number of bits in the exponent including its sign and bias — the same value as iexp for every format NumPy has (5 / 8 / 11).

public int nexp { get; }

Property Value

int

Remarks

NumSharp-only for decimal: 8, as iexp.

nmant

NumPy's nmant: the number of bits in the stored mantissa (the fraction, without the implicit leading 1) — 10 (float16), 23 (float32), 52 (float64 and complex128). eps == 2**-nmant for the IEEE formats.

public int nmant { get; }

Property Value

int

Remarks

NumSharp-only for decimal: 96, the bits of its integer coefficient.

precision

The approximate number of decimal digits to which this kind of float is precise.

public int precision { get; }

Property Value

int

resolution

The approximate decimal resolution of this type (10^-precision).

public double resolution { get; }

Property Value

double

smallest_normal

The smallest positive normal number.

public double smallest_normal { get; }

Property Value

double

smallest_subnormal

The smallest positive subnormal number.

public double smallest_subnormal { get; }

Property Value

double

tiny

The smallest positive usable number (alias for smallest_normal).

public double tiny { get; }

Property Value

double

Methods

ToString()

NumPy's repr(np.finfo(dtype)), the same text under every culture: finfo(resolution=1e-06, min=-3.4028235e+38, max=3.4028235e+38, dtype=float32).

public override string ToString()

Returns

string

The repr text.

Remarks

NumPy's finfo.repr, printed by Finfo(DType, double, double, double): the resolution through the dtype's own scalar str(), min / max through the dtype's _MACHAR_PARAMS printf format (%24.16e / %15.7e / %12.5e), the long double's and decimal's str(). A complex dtype reports its real part (dtype=float64). Never .NET's current culture (parity QA-41: this text was finfo(resolution=1E-06, min=-3.402823E+038, ...), with a decimal comma under de-DE and U+2212 minus signs under sv-SE).