I'm trying to get rid of floats in my functions.
I have one function that operates on a 16 bit integer value which is an upscaled 8 bit value. Then a downscaled 8 bit is sent to the output.
I'm sure I'm not explaining it well. Something like this:
int8 spot_value = 21; //arbitrary. just need a starting point
int16 running_value;
running_value = spot_value << 8; //multiply by 256 which is 5376
running_value += 154; //my upscaled value is now 5530
spot_value = running_value >> 8; //downscale again
if we were working with floats my downscaled value would be 21.6 which I could round easily to 22 and convert to an int8. But as-is it will truncate to 21 which I don't want.
Is there a way to "round" the integer up if it would have been appropriate to do so had it been a float but without converting anything to a float (even temporarily)?
It is probably a lot simpler than I'm making it out to be.