# Why isn't my Distance to Point scirpt working?

This topic is 4786 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am using the following code to calculate the distance between two 2d coordinates.
double PointDist(double x1, double y1, double x2, double y2){
double rise, run, length;
rise = y2 - y1;
run = x2 - x1;
length = sqrt(pow(rise, 2) + pow(run, 2));

return length;
}


The number I always get is 0.6000000x, where x is where the variation actually starts in the number thats returned. Heres a couple of numbers i got back. 0.60000002318111012 0.60000002075052783 Can anyone see the problem?

##### Share on other sites
Looks fine to me (aside from style issues). Have you tried verifying the inputs? (Or for that matter, the intermediate results of the pow()'s?)

##### Share on other sites

This topic is 4786 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

This topic is now closed to further replies.

1. 1
2. 2
3. 3
Rutin
20
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633655
• Total Posts
3013187
×