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?

2

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.