I am working on a program that could calculate to calculate pth percentile from an array of size n. I have to check whether the product p*n gives an int or a float...i want to do doing
percentile = p*n
if(percentile == int)
cant really figure out what to put instead of this int so that it would tell me whether percentile is an int or a float. thanx
These techniques are iffy at best. Remember that floating points are approximations and 10 might actually be 10.0000000001, in which case your above methods will fail.
double would be still inaccurate on it's lower bits.
You can test if two floating point numbers are approximately equal by testing if they are very close to each other :