I am very confused by the following results:
PRINT 3.1415926535897931 /180
Console result = 0.01745329251994329500
DECLARE @whatTheHell float(53)
SET @whatTheHell = 3.1415926535897931/180
PRINT @whatTheHell
Console result = 0.0174533
I don't understand because referring to this:
http://msdn.microsoft.com/en-us/library/ms131092.aspx
Sql Server Float should be equivalent to c# double. But when I compute this in c#:
double hellYeah = 3.1415926535897931 /180;
I get 0.017453292519943295...
I think you're getting confused by the fact that PRINT implicitly converts numeric to character with the default setting for the STR function -- a length of 10 (see MSDN). Try PRINT STR(@wth, 20, 16) and you might be happier.
Divide is not rounding. PRINT is rounding.
DECLARE
@var1 float,
@var2 float,
@var3 float
SET @var1 = 3.1415926535897931
SET @var2 = 180
SET @var3 = @var1 / @var2
SELECT @var1/@var2 as Computed, @var3 as FromVariable
PRINT @var1/@var2
PRINT @var3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With