0

Please tell me why I am getting a "bad operand type"

I'm trying to to do a comparison on a range of value.

Please help me fix.

if (-13683360 <= rgb <= -13683381)
2
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by tnimblett
0

It woiuld be nice if uou could use that syntax in Java, but you can't. It's not part of thelanguage.
-13683360 <= rgb evaluates to a boolean (true/false)
and then
(true/false) <= -13683381 is a bad operand because you cant't use <= with a boolean.
You need to break it into two comparisons the AND the reulsts together
(-13683360 <= rgb) && (rgb <= -13683381)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.