We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Warn when an unsigned value is negated. Example from a bug I had:
uint size = 5u; uint offset = -size // 4294967291 int offset = -size; // -5 float offset = -size; // 4.29497e+09 float offset = -5u; // Error: cannot implicitly convert expression `4294967291u` of type `uint` to `float`
Unsigned arithmetic is full of pitfalls. Even checked casts seem inconsistent.
uint(-5u); // 4294967291; int(-5u); // -5; int(4294967291) // Error: cannot implicitly convert expression `4294967291L` of type `long` to `int` int(4294967291u) // -5;
I'm not even sure why this happens when using this way of casting:
uint a = -5u; // 4294967291 float(-a); // 4.29497e+09 float(-5u); // Error: cannot implicitly convert expression `4294967291u` of type `uint` to `float` cast(float) -5u // 4.29497e+09
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Warn when an unsigned value is negated.
Example from a bug I had:
Unsigned arithmetic is full of pitfalls. Even checked casts seem inconsistent.
I'm not even sure why this happens when using this way of casting:
The text was updated successfully, but these errors were encountered: