Save float values in SQL Server

前端 未结 3 1484
青春惊慌失措
青春惊慌失措 2020-12-11 17:26

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

3条回答
  •  眼角桃花
    2020-12-11 17:45

    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.

提交回复
热议问题