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

fpnew: Fix f2i cast edge cases #64

Merged
merged 1 commit into from
Aug 30, 2022

Conversation

huettern
Copy link
Contributor

Fixes an edge-case where an overflow before rounding causes the integer output to overflow/wrap instead of clip.

The bug was found when converting the float 127.5 to an INT8 with RNE rounding. 127.5 is converted to 128 before rounding which resulted in the output 0x80 instead of 0x7f.

Original fix by @stmach.
Reviewed-by: Noah Huetter noah.huetter@axelera.ai

Reviewed-by: Noah Huetter <noah.huetter@axelera.ai>
@huettern huettern marked this pull request as draft August 23, 2022 12:31
@huettern huettern marked this pull request as ready for review August 23, 2022 12:31
@stmach
Copy link
Collaborator

stmach commented Aug 23, 2022

This bug appears when any float to int cast rounds the result up to positive INT_MAX + 1 (of the given integer format), irrespective of rounding mode and signedness.

@zarubaf
Copy link
Contributor

zarubaf commented Aug 24, 2022

I ❤️ Bug fixing

@zarubaf zarubaf merged commit e5c91fe into openhwgroup:develop Aug 30, 2022
anga93 pushed a commit to yvantor/fpnew that referenced this pull request Nov 21, 2022
Reviewed-by: Noah Huetter <noah.huetter@axelera.ai>

Co-authored-by: Stefan Mach <stefan.mach@axelera.ai>
msyksphinz-self pushed a commit to msyksphinz-self/fpnew that referenced this pull request Oct 21, 2023
Reviewed-by: Noah Huetter <noah.huetter@axelera.ai>

Co-authored-by: Stefan Mach <stefan.mach@axelera.ai>
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

Successfully merging this pull request may close these issues.

3 participants