DECLARE @f AS FLOAT = '29545428.022495'; SELECT CAST(@f AS NUMERIC(28, 14)) AS value;
29545428.02249500200000
Today I read this example. I understand the problem of floating point numbers, but I don't understand the result of this casting. How it works?
UPDATE
First we can replace varchar in the first line, the result will be the same.
DECLARE @f AS FLOAT = 29545428.022495;
Secondly, I think the problem is casting. Try the following code.
DECLARE @f AS FLOAT = 29545428.022495; select @f - 29545428;
0,0224950015544891
Perhaps this is the reason 002
at the end. It works with other numbers.
UPDATE 2
Well, I think I get it wrong. Here's a related question and answer.
source share