Bitwise operations in Scala (in fact in any language) return a result of type Int
, your if expression requires a type of Boolean
. Scala doesn't treat Boolean
values like C, where you code would work fine.
You can make your expression return a Boolean
by testing explicitly for 1
:
if((c & (1 << j)) != 0)