Made the type conversions more explicit so that it's clear
that we get as an intermediate result an int and that the
input and output are short int.