SqlCeServer: Float stores incorrectly
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 a开发者_开发问答re skewed.
When I enter
0.006, the database will store0.0060000000521540642When I enter
0.012, the database will store0.0120000001043081When 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
From msdn:
"not all values in the data type range can be represented exactly. "
Looks like you have found some of them!
加载中,请稍侯......
精彩评论