【发布时间】:2021-03-28 06:20:38
【问题描述】:
在我的 SQL 数据库中,我有一个表
(Product)
(
Item nvarchar(50),
Price real
)
在我的 C# winform 应用程序中,我有一个该表的类对象
class Product
{
string Item;
double Price;
}
using binding source, I bind the text property of textbox1.text to Product.Item
and
textbox2.text to Product.Price.
data in my table in the database is as follows,
Item = Item1
Price = 90.53
当我的应用程序中表示相同的数据并绑定到我的两个文本框时, textbox1.text = Item1(这里没有问题) 但 textbox2.text = 90.529998779296875 而不是 90.53。
我不知道是什么让数据库中的 90.53 在我的文本框中表示为 90.529998779296875?
【问题讨论】:
-
为什么要使用近似数据类型([real], [float(24)])来表示货币(Money [money], [smallmoney])?使用小数。
-
用于浮点数值数据的近似数数据类型。浮点数据是近似的;因此,并非数据类型范围内的所有值都可以准确表示。 real 的 ISO 同义词是 float(24)。 docs.microsoft.com/en-us/sql/t-sql/data-types/…
标签: c# sql winforms textbox double