Fast midpoint between two integers without overflow
If I ever create a programming language, one thing I'd like to try is to promote integer operations to larger types, so there is never overflow. For example, if a and b are int16, then a+b is int17, and (a+b)/2 is int16 again.<p>In practice you'd store them in the next larger integer, so 32 bits for a 17 bit int. If you really want to cut off bits or overflow, you use a cast or modulo.<p>It seems really weird that the "correct" way to do this calculation is to resort to bit manipulation (which should be an implementation detail IMO).