[Cs3] on operator precedence

Mikhail Nesterenko mikhail at cs.kent.edu
Wed Sep 20 11:34:32 EDT 2017


CS3 students,

Last time, I got tripped up by the following expression

     !(*it) % 2

It turns out that logical not has higher precedence than arithmetic
operations, including remainder. On the other hand, indirection
(dereference) has higher precedence than arithmetic operations as
well.

So, to negate the results of the remainder the proper expression
should be:

       !(*it % 2)

Thanks,
-- 
Mikhail


More information about the cs3 mailing list