I have a FLOAT
column in a SQL Server database that appears as follows in SQL Server Management Studio.
18.001
When I read that value into a float
variable, and format it using sprintf()
("%f"), it appears as:
18.000999
When I read that value into a double
variable, and format it using sprintf()
, it appears as:
18.001000
Could I get some suggestions on this? The values being stored are generally under 100, with up to 3 decimal places. What is the best SQL Server type? What is the best C++ type? And should I be using some rounding technique to get it in the format I want?
Note: I'm not actually using sprintf()
, I'm using CString.Format()
, but the expected behavior is the same.