J
John
I came across this nugget in my intarweb travels. It's part of a
median-calculation. Can someone tell me what the if( length & 0x1 ) is
doing?
Thanks!
---------------------------------------------
/* Is vector length odd or even ? */
if (length & 0x1)
ans = pCopy[length/2];
else
ans = .5 * (pCopy[length/2 - 1] + pCopy[length/2]);
median-calculation. Can someone tell me what the if( length & 0x1 ) is
doing?
Thanks!
---------------------------------------------
/* Is vector length odd or even ? */
if (length & 0x1)
ans = pCopy[length/2];
else
ans = .5 * (pCopy[length/2 - 1] + pCopy[length/2]);