user1050619
user1050619

Reputation: 20866

Comparing 2 float values in sqlserver

I have a float variable-field1 in 2 tables-table1 & table2. When I query the table and check the values of the field both look identical but when I find their difference it gives a difference instead of zero.

Field1(Table1) value---84.4660194174757
Field2(Table2) value---84.4660194174757

Differnce---1.4210854715202E-14

Why would I get this problem?

Upvotes: 17

Views: 35659

Answers (1)

gbn
gbn

Reputation: 432331

  • Use ROUND to limit the decimal places
  • Use ABS(value1-value2) < 0.00001 with some suitable value
  • Don't use float

Upvotes: 30

Related Questions