Messages in this thread | | | From | "Rafael J. Wysocki" <> | Subject | Re: [PATCH 6/7] cpufreq: intel_pstate: Trivial code cleanup | Date | Wed, 11 Jun 2014 02:23:27 +0200 |
| |
On Tuesday, June 10, 2014 02:26:45 PM Joe Perches wrote: > On Tue, 2014-06-10 at 23:38 +0200, Rafael J. Wysocki wrote: > > > > > is. And the result of (a * 100) / b may generally be different from > > > > a * 100 / b for integers (if the division is carried out first). > > > > > > I thought that (a * 100) / b is always equivalent to a * 100 / b. > > > > I'm not actually sure if that's guaranteed by C standards. > > It is. left to right, same precedence. > > > It surely > > wasn't some time ago (when there was no formal C standard). > > c89 is 25 years ago now.
Apparently, I'm old.
> > Either way, in my opinion it's better to put the parens into the expression > > in this particular case to clearly state the intention. > > I don't think so.
Of course, you're free to disagree, but I guess you'll admit that a * b / c is generally different from b / c * a and if you see something like this it is hard to say at first sight whether or not this is intentional or an expression ordering bug.
Rafael
| |