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

Slightly problematic float->int conversions #55

Closed
m8pple opened this issue Apr 27, 2018 · 1 comment
Closed

Slightly problematic float->int conversions #55

m8pple opened this issue Apr 27, 2018 · 1 comment

Comments

@m8pple
Copy link
Contributor

m8pple commented Apr 27, 2018

The docs explain that only round-nearest-even is supported, which
is fine for all the normal operators, but a bit more problematic for
float -> int conversion where it is likely we need more control.

Given the lack of math.h, people will reach for int x=(int)f;, but the implementation
applies RNE, so we lose compatibility with C which expects RTZ, and code will
silently break. This can be problematic for things like special functions, where
there is often table-lookup for coefficients based on an integer/fractional split.

If the altera float->fixed IP supports a dynamic rounding config, could that
be used to support both RTZ and RNE (and RDN & RDU)?

If not, it would be helpful to add modes to the existing elf checker somehow,
so that people know if an unsupported rounding mode had crept in.

@mn416
Copy link
Collaborator

mn416 commented Apr 27, 2018

Hi David,

Unfortunately, RNE is all the float -> int core gives us.

We could try the float -> 32.32 fixed-point converter and then implement the rounding manually.

Am open to a pull request for the ELF checker :)

In the meantime, I'll reference this issue in the limitations section.

Thanks,

Matt

mn416 added a commit that referenced this issue Apr 27, 2018
@m8pple m8pple closed this as completed May 4, 2018
mn416 added a commit that referenced this issue May 17, 2019
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

2 participants