From ASMBits

Sometimes when doing arithmetic, it is better to "saturate" (or clamp) numbers that overflow to the maximum possible value rather than wrap around.

Write a function that will convert an unsigned 32-bit number to 16 bits. If the 32-bit number is too big to fit, saturate (or clamp) the output to the maximum possible unsigned 16-bit value.

unsigned short saturate(unsigned int n);

Sample Input


Sample Output


Write your solution here

Upload a source file...