2

I have a column in a T-SQL database that consists of real values, but when I convert it to double I get something different than what was stored.

For example, I pick one row which has 1.15 stored. When I convert it with:

Convert.ToDouble(reader["VAT"]);

I get:

1,14999997615814

Why? And how do I convert a real to double and recieve the same value?

Dave
  • 71
  • 8

1 Answers1

2

Try to change the data type of your column from real to float. If you visit this link, you will notice that float SQL Server data type maps to Double, Nullable<Double> CLR types. On the other hand, real SQL Server data type maps to Single, Nullable<Single> CLR types. I suspect that's your problem.

Christos
  • 53,228
  • 8
  • 76
  • 108