-
Notifications
You must be signed in to change notification settings - Fork 221
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
VB -> C#: (int)Math.Round(x)
is used instead of Convert.ToInt32(x)
#1082
Comments
Both are equivalent.
|
Although they boil down to equivalent code I would still prefer |
I forgot to say that I just meant that its priority is lower than you think. Both results are fine for me. |
Convert.ToInt32(1.5M) == 2
&&
(int)1.5M == 1 && decimal.ToInt32(1.5M) == 1
&&
(int)Math.Round(d) == 2
I would need to check every time what's the default value for |
It confuses those who mainly use C/C++, Java, and JS, as you think. |
VB.Net input code
Erroneous output
This isn't broken (I don't think so), just very confusing to suddenly see rounding where there previously was none.
Expected output
This has the additional benefit of looking the same as the VB.NET code decompiled to C# looks like:
SharpLab
Interestingly,
explicit operator int(Decimal value)
seems to do things slightly differently, so(int)d
may not be the same asConvert.ToInt32(d)
.Details
The text was updated successfully, but these errors were encountered: