Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server makes up extra precision for floats?

Precision loss is one thing, but precision gain???

I have a text file w/ the following coordinates:

41.88694340165634   -87.60841369628906

When I paste this into SQL Server Mgmt Studio table view, it results in this:

41.886943401656339  -87.608413696289062

Am I dreaming? How is this possible?

I'm pasting from notepad, and it's raw text. Same problem if I type the characters directly.

Where does sql server get the extra precision from?

like image 821
Scott Klarenbach Avatar asked Dec 29 '25 22:12

Scott Klarenbach


1 Answers

It's not adding precision, it's just rounding it to the nearest IEEE floating point representation. When you convert that back to decimal, it only LOOKS like it gained precision.

like image 124
hova Avatar answered Dec 31 '25 15:12

hova



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!