Content-Length: 211986 | pFad | http://github.com/francof2a/fxpmath/issues/86

0F Feature Request: New rounding mode · Issue #86 · francof2a/fxpmath · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: New rounding mode #86

Open
danilo-bc opened this issue Oct 5, 2023 · 1 comment
Open

Feature Request: New rounding mode #86

danilo-bc opened this issue Oct 5, 2023 · 1 comment
Milestone

Comments

@danilo-bc
Copy link

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 rule shall be used for all rounding modes when the two nearest representable numbers are not at equal distance. When the two nearest representable numbers are at equal distance, this rule implies that there is rounding toward plus infinity [...].

This means that it isn't compatible with any current rounding mode, including 'around', which uses even rounding.

A practical example:

x = Fxp(0.1689453125, n_word = 12, n_int = 2, rounding='around')
#                                       fxp-s12/9(0.16796875)
# Expected value for new rounding mode: fxp-s12/9(0.169921875)
@francof2a francof2a added this to the v0.5.0 milestone Feb 8, 2024
@nozomioshi
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/francof2a/fxpmath/issues/86

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy