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

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

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -