a && b returns 1 when both a and b are nonzero , and not only when they are equal to 1. Otherwise, it returns 0.
a || b a || b returns 1 when at least one of a or b is nonzero , and not just when one of them is 1. Otherwise, it returns 0.
To give a few examples:
0 && 0 -> 0 1 && 0 -> 0 1 && 1 -> 1 2 && 1 -> 1 -1 && -1 -> 1 -100 && 0 -> 0 0 || 0 -> 0 1 || 0 -> 1 0 || 1 -> 1 -1 || 0 -> 1 -100 || 20 -> 1
source share