I’m trying to compare an integer and a double:
printf("%d\n", pos<(td+tr));
if(td <= pos < (td+tr))
{}
The print statement evaluates the comparison pos<(td+tr) properly. The if(td <= pos < (td+tr)) comparison does not evaluate properly.
Pos is an int: int pos;
td and tr are doubles: double td,tr;
is evaluated left to right. So first
is evaluated to a truth value. And then that truth value is compared with
td+tr.That’s not what you want. You want