This is generally how these things work.
Bitwise operations perform Boolean operations on the bits representing their operands. Logical operations are Boolean operations performed on Boolean sets, usually TRUE and FALSE or 1 and 0. A Boolean set could be any group of distinct items where the total count of set members is 2.
In the case of performing bitwise AND on the operands 7 and 15: if the system you're using represents them as straight binary numbers with no weird offsets then 7 becomes 0111 in binary, 15 becomes 1111 in binary. The leading 0 on binary 7 is not necessary as it is the same as prepending a zero to any decimal number: 10 = 010 = 000000000000010, it's easier to illustrate the operation with the leading zero though.
0111 7 in binary
1111 15 in binary
&&&& bitwise AND
0111 results in 7
if true
and false
are represented as binary 1 and 0 then there is no difference between the "logical" and
and the "bitwise" and
operations.
1 true as binary 1
0 false as binary 0
& either logical or bitwise AND
0 results in binary 0
try bitwise and
on some other numbers like say 1 and 2
01 1 in binary
10 2 in binary
&& bitwise and
00 results in binary 0
Assuming that any number except 0 will be converted to true
, performing a "logical" and
on the numbers 1 and 2 would yield a different result
1 the number 1 converted to true and represented as boolean 1
1 the number 2 converted to true and represented as boolean 1
& logical and
1 results in true, here represented as binary 1
When performing bitwise operations involving floats, negative numbers, or basically anything other than positive whole numbers, you may end up with radically different results. This is due to different environments using different methods for storing numbers in memory. For sure, it's all binary but, the number line isn't always centered on binary zero and it's not always the case that every bit represents part of the number; some of the bits could represent the sign of the number or the exponent. You'll have to dig down into the implementation details if you want to just toss decimal numbers into bitwise operations. It's easier to deal with if you have a method of converting the numbers to binary because then you know the bits and their order exactly and, you'll be able to test whether your expectations match your results.