Reputation: 148524
I think Im going mad
SELECT 30.0/(-2.0)/5.0;
SELECT 30.0/-2.0/5.0;
what is happening here ?
who said that x/(y)/z
will be (x/y)/z
and not x(y/z)
? –
Upvotes: 2
Views: 167
Reputation: 238106
Your second select is executed as:
select 30.0/-(2.0/5.0)
Looks like the minus sign causes SQL Server to invert the last division-- pretty sure that's a bug!
Upvotes: 3
Reputation: 103597
SELECT 30.0/(-2.0)/5.0;
is fairly clear:
SELECT 30.0/(-2.0)=-15.0
-15.0/5.0=-3.0
the second select is being interpreted as: SELECT 30.0/-(2.0/5.0);
2.0/5.0=0.4
30.0/-0.4=-75.0
see: Operator Precedence (Transact-SQL)
Upvotes: 7