float type containing int type ifmt * slope + inter
Return float type that can represent the max and the min of the ifmt type after multiplication with slope and addition of inter with something like np.array([imin, imax], dtype=ifmt) * slope + inter.
Note that slope and inter get promoted to 1D arrays for this purpose to avoid the numpy scalar casting rules, which prevent scalars upcasting the array.
Parameters: | ifmt : object
slope : float, optional
inter : float, optional
default_out : object, optional
|
---|---|
Returns: | ftype : object
|
Notes
It is difficult to make floats overflow with just addition because the deltas are so large at the extremes of floating point. For example:
>>> arr = np.array([np.finfo(np.float32).max], dtype=np.float32)
>>> res = arr + np.iinfo(np.int16).max
>>> arr == res
array([ True], dtype=bool)
Examples
>>> int_scinter_ftype(np.int8, 1.0, 0.0) == np.float32
True
>>> int_scinter_ftype(np.int8, 1e38, 0.0) == np.float64
True