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

convert 32f->32i: fix compiler warnings about loss of int precision #665

Merged
merged 1 commit into from
Oct 22, 2023

Conversation

marcusmueller
Copy link
Member

This feels like someone else probably has an open PR about it already, but I can't find it.

Compilers warn that converting INT_MAX to float leads to INT_MAX+1 as float value.

That's absolutely not surprising: bits(single precision float mantissa) < bits(int), so an int of value 2^N - 1 must inherently be non-representable for N close to bits(int), and MAX_INT = 2³²-1.

So, the upround that I'm doing here explicitly is always done, on every machine I could think of, and so what this compiler warning silencing does is always done, anyways.

Finally makes VOLK a zero-warning compile on my clang16 x68_64 avx2 machine.

Compilers warn that converting INT_MAX to float leads to INT_MAX+1 as
float value.

That's absolutely not surprising: bits(single precision float mantissa)
< bits(int), so an int of value 2^N - 1 must inherently be
non-representable for N close to bits(int), and MAX_INT = 2³²-1.

So, the upround that I'm doing here explicitly is always done, on every
machine I could think of, and so what this compiler warning silencing
does is always done, anyways.

Finally makes VOLK a zero-warning compile on my clang16 x68_64 avx2
machine.

Signed-off-by: Marcus Müller <[email protected]>
Copy link
Member

@argilo argilo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, and this shouldn't change the behaviour.

Copy link
Contributor

@jdemel jdemel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jdemel jdemel merged commit 3968007 into gnuradio:main Oct 22, 2023
32 checks passed
Alesha72003 pushed a commit to Alesha72003/volk that referenced this pull request May 15, 2024
convert 32f->32i: fix compiler warnings about loss of int precision
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