In Microsoft's SQL Server, select 7/4, 7.0/4 tells us that:
That is all...
Ok, that not all. This little quirk bit me, hard. It should be explained.
Basically, all constant values have an assumed data type. The value 7 is assumed int, 7.0 assumed float. If all elements are int, then the desired result is assumed to be int. And if you're doing math with variables that are all int? You have to play cast games.
I suppose I wouldn't mind this as much if select 'Value=' + (7.0/4) didn't give Error converting data type varchar to numeric.. Value assumptions are nice, but they should be consistent. I'd much prefer the assumptions never presumed I actually wanted to loose precision, like the fraction rounding does.
7/4 == 1 7.0/4 == 1.75
That is all...
Ok, that not all. This little quirk bit me, hard. It should be explained.
Basically, all constant values have an assumed data type. The value 7 is assumed int, 7.0 assumed float. If all elements are int, then the desired result is assumed to be int. And if you're doing math with variables that are all int? You have to play cast games.
declare @n int, @d int select @n=7, @d=4 print @n/@d -- yields 1 print cast(@n as float)/@d -- yields 1.75 print cast(@n/@d as float) -- yields 1, cast too late
I suppose I wouldn't mind this as much if select 'Value=' + (7.0/4) didn't give Error converting data type varchar to numeric.. Value assumptions are nice, but they should be consistent. I'd much prefer the assumptions never presumed I actually wanted to loose precision, like the fraction rounding does.
From:
no subject
Microsquish's Excel math has had lots of problems which I've heard tell only get worse with this Office XML format they have now.
From:
no subject
Microsoft's XML is a joke and always has been. It's worst kind of tech, playing to the gods of Buzzword and PR, please don't invoke a call to Substance lest you banish the carefully crafted illusion. That illusion is propped up on a telephone book size spec.
This guy actually took the time to read the spec. Yeah, it's crap. (http://www.robweir.com/blog/2007/07/formula-for-failure.html)