问题描述
我目前正在 MSDN 并遇到过以下短语.
I'm currently learning "numeric" data type on MSDN and have encountered the following phrase.
从十进制或数字转换为浮点数或实数会导致一些精度损失.从 int、smallint、tinyint、float 转换,real、money 或 smallmoney 转换为十进制或数字可能会导致溢出.
Converting from decimal or numeric to float or real can cause some loss of precision. Converting from int, smallint, tinyint, float, real, money, or smallmoney to either decimal or numeric can cause overflow.
我真的不明白转换十进制或数字"数据类型时精度损失/溢出背后的原因.有人可以给我解释一下吗?
I dont really understand the reason behind loss of precision/overflow when converting "decimal or numeric" data type. Could someone please explain it to me?
推荐答案
Decimal 或 Numeric 数据类型实际上是带有小数分隔符位置的整数.关于声明的精度,它们可以存储最小值和最大值之间的每个值.正如 Ryan 所说,您可以在从 -32k 到 32k 的四个字节内存储大约 64k 个不同的值.如果你创建一个四字节的浮点类型,范围会更广,但仍然有 64k 不同的值要存储.范围内的某些值无法精确存储.
Decimal or Numeric data types are in fact integer with decimal separator position. They can store each value between min and max values, regarding declared precision. As Ryan said, you can store approx 64k different values within four bytes ranging from -32k to 32k. If you make a four bytes float type, the range would be much wider, but there are still 64k different values to be stored. Some of the values within the range are impossible to be stored precisely.
这篇关于转换“十进制或数字"时精度丢失/溢出的原因;数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)