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

comparing floating-point with ‘==’ or ‘!=’ is unsafe #99

Open
mdykierek opened this issue Jun 28, 2022 · 0 comments
Open

comparing floating-point with ‘==’ or ‘!=’ is unsafe #99

mdykierek opened this issue Jun 28, 2022 · 0 comments

Comments

@mdykierek
Copy link

Both gcc and clang have switches and warnings for that:

  • warning: comparing floating-point with ‘==’ or ‘!=’ is unsafe [-Wfloat-equal]

MISRA Rule 6–2–2 Floating-point expressions shall not be directly or indirectly tested for equality or inequality.

There are several uses for both variable and literal comparison (against 0 e.g.).

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

1 participant