Suppose we have some variables x and y, and the following if statement which involves bit shifting:
if (x<<y)
I've read some posts which also deal with the issue of using bit shifting with variables (of some type) and inside if statement, but unfortunately I haven't been able to reach a unequivocal conclusion whether it is an error or not.
I assume that if it is an error, then it's a semantic error or a run-time error .
But is it necessarily en error ?
x << y
is an expression which is evaluated and giving a certain result. Then this result is interpreted as condition forif
statement. – Eugene Sh. Jul 18 '19 at 22:24if ((x << y) != 0)
would make it explicit what you're intending to do. (Although in that case I'd be inclined to use a bit mask test.) – 1201ProgramAlarm Jul 18 '19 at 23:30