enrique

07-16-2009, 09:53 AM

Since logical && and || need to be evaluated component-wise for vectors, are c[0] and c[2] the only components that need to be evaluated because only b[0] and b[2] were nonzero? What if the RHS of && is a complicated expression(e.g. b&&foo())? Is the statement about evaluating the RHS only when LHS is equal/unequal to 0 meant only apply when both operands are scalar?

int4 a;

int4 b=(int4)(1,0,1,0);

int4 c=(int4)(10,10,10,10);

a=(b&&--c);

//a is (-1,0,-1,0) but should c be now (9,10,9,10) or (9,9,9,9)?

The 1.0 spec states:

"And (&&) will only evaluate the right hand operand if the left hand operand compares unequal to 0. Or (||) will only evaluate the right hand operand if the left hand operand compares equal to 0. For built-in vector types, the operators are applied component-wise"

int4 a;

int4 b=(int4)(1,0,1,0);

int4 c=(int4)(10,10,10,10);

a=(b&&--c);

//a is (-1,0,-1,0) but should c be now (9,10,9,10) or (9,9,9,9)?

The 1.0 spec states:

"And (&&) will only evaluate the right hand operand if the left hand operand compares unequal to 0. Or (||) will only evaluate the right hand operand if the left hand operand compares equal to 0. For built-in vector types, the operators are applied component-wise"