I am working on a platform that only has integer arithmetic. The application uses geographical information, and I present the points at the coordinates (x, y), where x and y are the distances measured in meters. As an approximation, I want to calculate the Euclidean distance between two points. But for this, I have square distances, and with 32-bit integers the largest distance I can represent is 32 kilometers. Not good. My needs are more than about 1,000 kilometers. But I would like to be able to allow distances on a scale of less than 30 meters.
Therefore, my question is: how can I calculate the Euclidean distance using only integer arithmetic without overflow , at distances whose squares do not fit in a single word?
ETA: I would like to be able to calculate distances, but I could agree to be able to compare them.
source share