first of all: I know some best practices and work-arounds when working with float numbers, I just want to understand
An older topic tried to explain the difference between
SELECT ROUND ('6.465',2) --- result 6.46
SELECT ROUND (6.465,2) --- result 6.47
It's because you're relying on an implicit conversion from a string to a decimal data type which SQL server will do to 2 decimal places by default...
SELECT ROUND (CONVERT(DECIMAL(3,2),'6.465'),2) --- result 6.47
Now please explain this:
SELECT ROUND('0.285',2) -- 0.28
SELECT ROUND(0.285,2) -- 0.29
SELECT ROUND (CONVERT(DECIMAL(3,2),'0.285'),2) --- result 0.29
The string value does not seem to be converted to decimal with 2 decimal places.
MS is on the safe side with mentioning
the last digit is always an estimate
But because the result of the estimate is always the same, I would like to know:
* how is a string value exactly implicitly converted?
* how exactly does the estimation work, that in case of doubt rounds a value up or off?