4 ms·
Or x / 2 + y / 2 + (x & y & 1) Edit: This is the same you wrote, but it gets the wrong number for negative values, for negative ints the rounding will go
by Jensson 4y ago
Or
x / 2 + y / 2 + (x & y & 1)
Edit: This is the same you wrote, but it gets the wrong number for negative values, for negative ints the rounding will go up and not down.