supposing to have two arrays a[N],b[N] containing only 0 and 1 values, is there a way to calculate c = a || b without a loop like the following (in C)?
#define N 10
char a[N];
char b[N];
char c[N];
// suppose to do some operations on a and b so that
// for each i a[i] == 0 or a[i] == 1
// and the same for b
// this is the loop i would want to avoid
int i;
for(i=0;i<N;i++)
c[i] = a[i] || b[i];
I would want to calculate the result of (a || b) directly comparing the two memory areas, but i don’t know if it’s possible.
thank you very much for your attention.
Since bitwise or is an operation that has to be applied to a single value, I don’t think there is. Is there a particular reason you want to avoid the loop? If it’s a hassle, making a function out of it is easy.
Edit: The question has now changed to logical OR, but I don’t think the answer is much different.