Aha! There is a work around for neg numbers?
I was working circle fill routines with same formula as Terry had shown and got hung by negative value coming up somewhere in calculation both SQR and ^.5, crash.
Wait how can you get a neg when A * A + B * B would cancel it? Don't know but I had a circle fill routine that refused to work unless I loose time to check for negs or loose time calling ABS.
Hmm... now I wonder if, .... no I was still not using Octants back then.
But I see now the formula does use ABS calls, well the one from Wiki, if Steve is corrrect:
I think what the gcc compiler does is a little more:
IF x < y then
if x = 0 return y
return x * sqrt(1 + y / x * y / x)
Else
if y = 0 return x
return y * sqrt(1 + x / y * x/ y)
End If
Which saves a few function calls, but is still more complicated than the direct math would be.
Then gcc compiler might not be doing enough, I think the ABS calls are needed.
Come to think, I might have been getting negative numbers because the type I was using was too small?
350 * 350 > integer range but I don't think I was working in integers... I digress.