Paolo Lemos wrote:I want to know why is this, and the same happens in C++ with doubles.
Simply put: because doubles are NOT exact, so it's quite possible that your divisions never end up equal.
And why would you think that 8 would be special? √8 is irrational from what I recall (it has been a long time though). √9 on the other hand...
I suspect that it works for
float because calculations are actually done with doubles and then converted; but I wouldn't stake my life on it.
For more information, read
this.
Winston