Sorin Petcu (8/7/2008)
rbarryyoung (8/7/2008)
Actually, it was not any trick here. Because someone would select 16^16 which returns 0. And this means that the input for sqrt will be a negative number. According to BOL, sqrt should receive negative numbers also (float).
Except that it has to return a float. And the float data type is defined as
a number in the range - 1.79E+308 to -2.23E-308, 0 and 2.23E-308 to 1.79E+308
i is not in that range. it's complex and falls outside of the non-imaginary number range. Hence SQRT which must return a float will throw a domain error.
Heck I got it wrong... because I remembered from the days of Pascal I think using ^ as the exponent operator... but once I learned about it being the XOR operator I could accept my wrongness... this is a good tricky question!