Sorin Petcu (8/8/2008)
I think you don't understand or you don't want to understand.
Let me see: how it is represented the number -5 in computer? as binar form as 1111111111111111111111111111111111111111111111111111111111111011 and this number would be reconverted as 18446744073709551611 in decimal format.
So, SQRT(-5) would be what? guess what:
select SQRT(18446744073709551611) = 4294967296
So we are talking only about numbers and not math theory. You said forth and forth about complex numbers. Wrong! Why you want to receive a complex number from a function built in a programming language? Why you want all the time that float number can't be asimilated as complex number? It is nothing to do with complex numbers in a programming language or an engine like sql server. Complex numbers are in math theory. So wake up!
-5 in binary is what is below for a 64 bit integer (notice how it's 65 bits long).
1111111111111111111111111111111111111111111111111111111111111011 when converted to an unsigned integer is 18446744073709551611, when converted to a signed integer it's -5.
Just because you're using Calc to do the conversions... it doesn't apparently handle converting negative numbers to binary and back. Take -5 convert it to binary... convert it back... it should be
I'm sure you will agree that 18446744073709551611 is not equal to -5.
Do you understand how to actually convert binary to decimal?
It's interesting that you've perhaps pointed out a bug in calc.exe though.. if you use excel and do a DEC2BIN of -5 you get 1111111011 and if you use BIN2DEC to convert it back you'll get the correct answer which is -5.
Here's an example in SQL