In this particular case, no, there is no difference in the result:
1 || 0 == 1 1 | 0 == 1
all truth tables apply here.
If you are talking about how we came to the result, then there may be a difference. Using || you have a short circuit mechanism:
BOOLEAN bFooBar = (bFoo||bBar) // if bFoo is TRUE, we never look at bBar // vs BOOLEAN bFooBar = (bFoo|bBar) // where we take into account both values
So long and short, yes, you may not use logical and bitwise operators correctly in some cases and get the same results, but why would you ever do that? If you know that this is wrong, and you know that it can lead to bad things, itβs hard to find mistakes, use the tools that the language provides for the tasks that they should do.
source share