266581 (2) [Avatar] Offline
First of All, congratulation for the fantastic book.
C# in depth is my favorite programming book.
I have all editions.

I think there is a little mistake in the euclidian distance equation:
In the book the equation is:

Math.Sqrt(X * X + Y * Y);

but, I think should be:

Math.Sqrt(X * 2 + Y * 2);

Best Regards,
jon.skeet (465) [Avatar] Offline
Nope, it's definitely meant to be x*x + y*y. It's "the root of x squared + y squared"... and there's no "power" operator in C#, so the easiest way of squaring something is just to multiply it by itself. (Your suggested code would multiply by 2, not take the value to the *power* of 2, which is different.)
266581 (2) [Avatar] Offline
Sorry Jon,

My mistake. I was reading in the mobile, and "*" seems like "^".
I use R too , and in R "^" is a potency operator, but in c# is used for XOR.
I did read X^X + Y^Y (My wife is right, I really need Bifocals)