惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Proofpoint News Feed
Attack and Defense Labs
Attack and Defense Labs
Security Archives - TechRepublic
Security Archives - TechRepublic
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MyScale Blog
MyScale Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
F
Full Disclosure
云风的 BLOG
云风的 BLOG
爱范儿
爱范儿
V2EX - 技术
V2EX - 技术
B
Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
M
MIT News - Artificial intelligence
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
W
WeLiveSecurity
Stack Overflow Blog
Stack Overflow Blog
TaoSecurity Blog
TaoSecurity Blog
T
Threatpost
小众软件
小众软件
T
The Blog of Author Tim Ferriss
Google Online Security Blog
Google Online Security Blog
MongoDB | Blog
MongoDB | Blog
T
Tenable Blog
P
Privacy International News Feed
S
Security @ Cisco Blogs
H
Heimdal Security Blog
大猫的无限游戏
大猫的无限游戏
B
Blog RSS Feed
H
Help Net Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
C
Cisco Blogs
酷 壳 – CoolShell
酷 壳 – CoolShell
P
Proofpoint News Feed
D
Darknet – Hacking Tools, Hacker News & Cyber Security
有赞技术团队
有赞技术团队
Application and Cybersecurity Blog
Application and Cybersecurity Blog
O
OpenAI News
Security Latest
Security Latest
S
Securelist
Cyberwarzone
Cyberwarzone
D
Docker
S
Schneier on Security
V
Vulnerabilities – Threatpost
The GitHub Blog
The GitHub Blog
P
Privacy & Cybersecurity Law Blog
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - zzzp0755

Docker集群 + 运维 + 镜像仓库 Docker安装和应用 linux常用命令 SQL Server 检测到基于一致性的逻辑 I/O 错误 校验和不正确(应为:010f28a5,但实际为:0xcaf47a0c)。 ABP vNext学习 及问题记录 winform datagridview 勾选复选框 和点击单元格事件区分 Vol.NET 开发步骤 .net6.0 新知识学习 英语2025-02 Dev 案例 css 积累 20240423 JSON.NET JObject键比较不区分大小写 jsfiddle.net js在线调试 sql 时间日期函数 ele admin plus 添加dev插件 .NET Core Web API 实现图形验证码 DataGridView 保存编辑的行 .net webapi 返回类型
FLOAT:浮点数值数据的大致数值数据类型
zzzp0755 · 2024-08-30 · via 博客园 - zzzp0755

FLOAT类型的官方描述:

用于表示浮点数值数据的大致数值数据类型。浮点数据为近似值;因此,并非数据类型范围内的所有值都能精确地表示。

上面已经告诉我们了一句话,就是不要太相信它喔。

TSQL提供了一个专门的代表实数的数据类型。事实上它提供了两种实数类型:REAL和FLOAT,不过这些数据类型和SQLSERVER的其他数据类型(其中一些类型据称是精确的类型)都不是严格数学意义上的实数系统。

数字的计算机表示对算数运算来说不是真实的,虽然它们可以满足大多数需求,但不能为所有问题提供“正确的答案”。

下面举例说明:

Real类型的不真实性:

这个不符合乘法的结合律a(bc)=(ab)c,但是对于SQLSever中实数和运算的表示,这两个式子则不相等,SQLServer在这一点上并没有任何错误,这样的结果符合浮点运算的重要IEEE标准。

Float类型的不真实性:

12.055进位应该是12.06结果却为12.05

另外的还补充一点,就是.NET中的Math.Round()这个函数默认的是采用银行家算法,这个函数还有哥带有枚举值的参数,这个参数可以指定使用哪种四舍五入的方法(其中包括传统的四舍五入的方法和采用银行家算法的四舍五入的方法)

如果使用 money 或 numeric 数据类型,那么,内部转换为 float 可能会降低精度。

所以在进行精确财务计算时,请尽量少使用float和real这样的数字类型,虽然这两种数据类型速度要快。
————————————————

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

原文链接:https://blog.csdn.net/lulei6/article/details/106686626/