Why are these answers different? Which one is correct? (Distance between to two 3D points)

103 Views Asked by At

I am calculating the distance between two 3D points in a program I am writing and using this math:

Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2) + Math.pow(z2 - z1, 2))

Wolfram Alpha Query #1, same as my answer == 234,976.6474396

Wolfram Alpha Query #2, different than my answer == 234,977

Which one is correct? Why are they different?

1

There are 1 best solutions below

2
On BEST ANSWER

You get the same effect if you ask for sqrt(1+1) versus distance between (0,0) and (1,1): the sqrt result has zillions of significant figures, but the distance result has only 6.

So this looks like a deliberate design decision, but I'm blowed if I can understand it.