round
From ZDoom Wiki
This function implements rounding. When performing the bitshift operation on a fixed point number, what you are actually doing is simply cutting off the end of the number, the part that is less than 1. So 0.5 >> 16 will return 0. There may be cases where you want to round values of 0.5 or greater to the nearest whole number instead when converting it to an integer, for example placing an absolute location for a hudmessage.
If you need to round a number to the nearest whole but need the resulting number as a fixed point, you can just bitshift it again in the opposite direction using round(number) << 16.
function int round (int fixednum) {
int retamount = fixednum >> 16;
if (fixednum % 65536 > 32767)
retamount++;
return retamount;
}

