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)

Recommended Answers

All 2 Replies

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)

Much obliged :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.