c++ - How can I check whether a double has a fractional part? -


basically have 2 variables:

double halfwidth = width / 2; double halfheight = height / 2; 

as being divided 2, either whole number or decimal. how can check whether whole number or .5?

you can use modf, should sufficient:

 double intpart;   if( modf( halfwidth, &intpart) == 0 )  {  // code here  } 

Comments

Popular posts from this blog

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

ruby on rails - Authlogic - how to make a registration and don't log in the new account? -