← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH 2/2] Remove questionable useless casts

 

Hi,

On Fri, Sep 06, 2019 at 10:09:07PM -0400, Reece R. Pollack wrote:

> >-                    const float posYfactor = (float)(windowsPos.y + y * 4.0f) / (float)m_windowSize.y;
> >+                    const float posYfactor = windowsPos.y + y * 4.0f / (float)m_windowSize.y;

> These are mathematically different expressions. You need to restore
> the parenthesis around the numerator expression even if you remove
> the cast.

Good catch, thanks!

> I would further argue that in many cases removing the cast is less
> clear than explicitly indicating how you want the expression
> interpreted, even if the expressions were the same.

Yes, my hope was that the first patch only had cases where the cast didn't
add any valuable information.

There are still a lot of places where the useless cast is part of a macro
or a printf statement, I've left those alone (that's also why I didn't add
a warning).

   Simon


References