C is not Python. The <
operator is binary and left-associative, so
SCALE_MIN < scale < SCALE_MAX
is parsed as
(SCALE_MIN < scale) < SCALE_MAX
The left hand side is either 1 or 0 (true or false), which is always smaller than SCALE_MAX
(which is 3). So your condition is always true. (Did you not get a compiler warning regarding that?)
Hint: you need to use the logical AND (&&
) operator to combine the two conditions.