-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Adding lint to detect lossy whole number floating-point literals #5160
Comments
I think if someone types out a float literal that are so long, that it cannot be represented in a float number, probably he/she wanted the exact number. So I think we can make this even a correctness lint. |
@clarfon Hey any thoughts on this? |
I agree-- don't we already technically have a lint for this? Maybe we'd make a warn-by-default lint for this? |
We have 3 lints addressing similar issues:
|
Of the three similar issues |
I think we can uplift |
Yeah |
Would adding a lint to detect whole number floating-point literals that are lossy when represented as floats be something useful. Here are a few examples:
For
f32
maybe we could suggest upcasting to anf64
. Not sure what we could suggest forf64
but we could at the least warn that the literal would be lossy. Would love to know your thoughts and if it is worth adding this to clippy then I can start working on it but if not feel free to close it.The text was updated successfully, but these errors were encountered: