I was reading some old game programming books and as some of you might know, back in that day it was usually faster to do bit hacks than do things the standard way. (Convert
Assignment to a volatile variable shold never be optimized away, so this might give you the result you want:
volatile
static volatile int i = 0; void float_to_int(float f) { i = static_cast(f); // has no side-effects }