In my debugger (VS2010), I can verify that I am sending the correct values to my SqlCeServer 3.5 database using an SqlCeCommand.
Looking at the data afterwards, I noticed that some of my float values are skewed.
-
When I enter
0.006, the database will store0.0060000000521540642 -
When I enter
0.012, the database will store0.0120000001043081 -
When I enter
0.011, the database will store0.0109999999403954
Other float values (1.125, 0.875, 0.75) store just fine.
Is there something special I have to do to ensure my float values store correctly?
Don’t use float: it’s approximate
Use fixed precision: decimal/numeric