SQL Rounding Problems in 2005 and 2000
I have a value in the database which is 2.700000002. When I run a query in Management studio in SQL SERVER 2005 I get 2.7. But when I run in SQL SERVER 2000 query analyzer 开发者_JS百科it comes 2.700000002.
2.70000002 is correct why is SQL SERVER 2005 trying to change the value by rounding it or selecting the floor value?
Exactly the same target server, database, datatype, processor, architecture etc?
If not, it's simply how the tools will display an approximate float value
Most things round off numbers for display.
~$ ghci
Prelude> 2.7
2.7
~$ irb
>> 2.7
=> 2.7
~$ python
>>> 2.7
2.7000000000000002
For interactive use, this is usually good enough — the only person to see the query analyzer is you, so why does it matter? For actual display, you should specify a format anyway. If you really need the exact value of "2.7"
, then you should be using a decimal type anyway, as countless articles and answers can tell you.
精彩评论