Median of interval

There are two methods to calculate the median of an interval [low, high].

  • m = ( l + h ) / 2
  • m = l + ( h – l ) / 2

l + h may have addition overflow, but h-l will not. Therefore, it is best to use the second method of calculation.

Leave a Reply

Your email address will not be published. Required fields are marked *