-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Too big float
to int
cast results nonsense
#17081
Comments
That's an implicit conversion. An explicit cast does not warn: https://3v4l.org/F9Ir7. Similarly implicitly converting this large In any case, given that this affects the core language functionality, this requires an RFC. |
As the first step of this/my feature request, I would expect The warning is second priority. |
Casting huge ints to floats also loses precision. Deciding what should warn and what shouldn't is not trivial. I also think this should be discussed first. |
In this issue I want to focus solely on https://3v4l.org/4gVYb behaviour which is very dangerous and not much expected from user POV. I would expect the resulting integer to be capped to |
float
to int
cast should emit warningfloat
to int
cast results nonsense
Description
repro: https://3v4l.org/0FJkO
I discovered this in library where big timeout was converted to milliseconds like
$timeoutFloat * 1000
and later casted into integer which resulted very dangerous0
without any warning.I would expect some warning like https://3v4l.org/4C3ru when too big float is impossible to be casted meaningfully into
int
.The text was updated successfully, but these errors were encountered: