Why is if (2 < 9 < 3) true?

( 2 < 9 < 3 ) is evaluated as ( ( 2 < 9 ) < 3).
In the first step 2 < 9 is evaluated to be true, which is represented as integer value 1 and results in ((1) < 3) for the second step.
That is obviously true.

You probably wanted something like ((x < val) && ( val < y)).

Leave a Comment