int ihypot(int x, int y) { if(x < 0) x = -x; if(y < 0) y = -y; if(x < y) Swap(x, y); if(y < (x >> 2) + (x >> 3)) return x + (y >> 3) + (y >> 5); y -= (x >> 2) + (x >> 5); return x + (y >> 1) + (y >> 4); }

This is approximation of sqrt(x*x + y*y).

- if max(x, y) < 168, absolute error < 4 (this has more to do with integer rounding)

- otherwise, the error is less than 2%

Putting it here so that perhaps it can be googled if somebody is looking for something like it...]]>