In my current project, the compiler shows hundreds of warnings about type conversions.
There is a lot of code like this
iVar = fVar1*fVar2/fVar3;
// or even
iVar = fVar1*fVar2/fVar3+.5f;
which intentionally assign float values to int.
Of course, I could fix these warnings using
iVar = (int)(...);
but that looks kind of ugly.
Would you rather live with the ugliness or live with the warnings?
Or is there even a clean solution?
Yes.
You should always fix the compiler warnings. Several reasons:
*) It may be the cause of an error and need an actual fix rather than just a cast. You won’t know until you look.
*) Actual coding errors that manifest as warnings can get lost in the noise generated by hundreds of warnings
*) It makes it clear to other coders that you really did mean to use that variable of the wrong type/sign there. That it is deliberate.
*) It makes it clear and explicit that the type and/or signedness is being changed. If your variable names do not contain an indication of the type and signedness it may not be obvious that this is occurring.