today have found that VS2010 do not support round
function in C++ projects. Info about that function have found here. Also noticed that there also no trunc
function.
So have tried some stuff and noticed some behavior that may help in such situation.
float a = 2.999;
int b = (int)a; //gives 2
float a = -2.999;
int b = (int)a; //gives -2
This works as truncation so I could use that, however I don't want to use code which leads to undefined behavior. So would like to ask if this is defined or undefined behavior.
EDIT: I'm not asking about C++11 as I'm using VS2008.