Wrong rounding the result of division

In reply to saritr:

Two issues:

  1. You are attempting to do arithmetic with 16 bit vectors where the intermediate results exceed 16 bits. This will result in overflow conditions affecting your results.

  2. You are attempting to conduct floating point arithmetic with integers.