Hacker News new | ask | show | jobs
by johnhenry 1589 days ago
I saw the title and thought to just do "(a / 2) + (b / 2)" and a do a little bit of fudging if a or b is odd.

After reading the article, learning that

  unsigned average(unsigned a, unsigned b)
  {
    return (a / 2) + (b / 2) + (a & b & 1);
  }

was once patented actually made me a bit sad for our entire system of patents.
1 comments

Why is math patentable? seems crazy to me
What is patentable is "this circuit to compute the average" where the circuit is an adder that drops the bottom bit from the addends, instead ANDing the two bottom bits and using the result as a carry-in.

Though actually it shouldn't be patented because it's an obvious implementation of a math formula (and math is not patentable).