Should you correct compiler warnings about type conversions using explicit typecasts?

Posted by BastiBechtold on Stack Overflow See other posts from Stack Overflow or by BastiBechtold
Published on 2010-12-21T09:42:22Z Indexed on 2010/12/21 9:54 UTC
Read the original article Hit count: 259

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?

© Stack Overflow or respective owner

Related posts about c++

Related posts about c