I have known that if we want to prevent overflow for integer type we can use long type to take it and compare the long type with Integer.MAX_VALUE. So how about float value?
for example
// Question: How do I prevent float overflow
private float distance(Point p, Cluster c){
float px = p.getX(), py = p.getY(), cx = c.getXMean(), cy = c.getYMean();
return (px - cx) * (px - cx) + (py - cy) * (py - cy);
}