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
Post a Comment