The FPU already does this for you.
//! Round double to integer
inline int iround(double v){
int retval;
\_\_asm fld qword ptr \[v\]
\_\_asm fistp dword ptr \[retval\]
return retval;
}
//! Round double to unsigned integer
inline unsigned int uround(double v){
unsigned retval;
\_\_asm fld qword ptr \[v\]
\_\_asm fistp dword ptr \[retval\]
return retval;
}