I have a simple web app , and want to save some numbers of Float or Double format in SQL server.
but there is a problem , when I try to save 123.66 , In Table I see 123.6600003662109 stored.
How nd why my float number changed when save on DB? how can I fix this error?
Thanks
You're not actually trying to save 123.66, because you can't represent 123.66 exactly as a float or double. The database is saving the data more accurately than you're used to, that's all.
If you want to save decimal numbers accurately, use the decimal
type.
See my articles on floating binary point and floating decimal point types for more info.
This is not a database issue, but a general problem with floating numbers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With