is there a way to check to see if a number is whole?
is there a way to check to see if a number is whole?
You can check a floating point number to see if it is whole like this:
#include <math.h>
.
.
double d = 3.0000001;
if (floor(d) == d)
cout << "Number is a whole number.\n";
many times floating points will not evaluate to whole numbers
because of a lingering supersmall fraction... instead you check for a range of accuracy....
float flA = 3.0;
int iA = (int)3.0;
if( (flA - iA) > .001 ) ......
zMan