Skip to main content



Defines utilities to work with numeric types.

You can import these APIs from the utils package. For example:

from utils.numerics import FPUtils


  • FPUtils: Collection of utility functions for working with FP values.
  • FlushDenormals: Flushes and denormals are set to zero within the context and the state is restored to the prior value on exit.


  • nan: Gets a NaN value for the given dtype.
  • isnan: Checks if the value is Not a Number (NaN).
  • inf: Gets a +inf value for the given dtype.
  • neg_inf: Gets a -inf value for the given dtype.
  • max_finite: Returns the maximum finite value of type.
  • min_finite: Returns the minimum (lowest) finite value of type.
  • max_or_inf: Returns the maximum (potentially infinite) value of type.
  • min_or_neg_inf: Returns the minimum (potentially negative infinite) value of type.
  • isinf: Checks if the value is infinite.
  • isfinite: Checks if the value is not infinite.
  • get_accum_type: Returns the recommended type for accumulation operations.
  • nextafter: Computes next representable value of arg0 in the direction of arg1.
  • ulp: Computes the ULP (units of last place) or (units of least precision) of the number.