Charming. Of course, this requires the #inclusion of <math.h>, (and the
first one requires <stdlib.h>, but you're more likely to have that
already), are probably massively less efficient than a straight
comparison, and can cause overflow that a simple comparison cannot.
Hmm. I had the impression that avoidance of any explicit
comparison/decision structure was the OP's _objective_.
From a mathematical standpoint, both expressions I'd given are correct, and
satisfy the OP's objective (assuming that I understood it correctly).
Oh, and it's spelled sqrt(), not Sqrt(), and the ^ operator does not do
what you think it does.
I never said I was writing anything in any computer language. Surely
if what I wrote did not make sense in a given language, one might
reasonably have assumed that it was not intended to be construed in that
language!
As I suppose you know, by writing (a-b)^2, I was indicating that (a-b) be
squared. And I intended to write Sqrt, rather than sqrt. In doing so, I was
following the convention according to which the principal value of a
multivalued relation is distinguished by capitalisation. For example,
according to that convention, asin(0) has an infinite number of values,
while Asin(0) has the single value 0.
Ben's solution is much better,
I too am a proponent of Iverson bracket notation. However, such a solution
does not meet the OP's objective, at least as I understood it.
David