Open danilo-bc opened 11 months ago
Prior to the release of v0.5.0, some data preprocessing can be performed by adjusting the values slightly through addition or subtraction of a extremely small number, in order to achieve the desired rounding effect.
An example for complex numbers in numpy.ndarray
:
precision = Fxp(signed=signed, n_word=n_word, n_frac=n_frac, rounding=rounding).precision
if isinstance(data, np.ndarray):
if isinstance(data.item(0), complex):
data = data + np.sign(data.real)*precision*1e-8 + 1j*np.sign(data.imag)*precision*1e-8
return Fxp(data, signed=signed, n_word=n_word, n_frac=n_frac, rounding=rounding)
Another fixed-point standard, included in IEEE's SystemC, has a mode SC_RND described in their manual, section 7.10.9.12 which states
This means that it isn't compatible with any current rounding mode, including 'around', which uses even rounding.
A practical example: