Paste: int16_nonzero_mask

Author: NIL
Mode: c
Date: Fri, 4 Oct 2019 23:11:17
Plain Text |
/* return -1 if x!=0; else return 0 */
static int int16_nonzero_mask(int16 x)
{
  uint16 u = x; /* 0, else 1...65535 */
  uint32 v = u; /* 0, else 1...65535 */
  v = -v; /* 0, else 2^32-65535...2^32-1 */
  v >>= 31; /* 0, else 1 */
  return -v; /* 0, else -1 */
}

New Annotation

Summary:
Author:
Mode:
Body: