<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Decimal</title>
	<atom:link href="https://www.aitaocui.cn/tag/233546/feed" rel="self" type="application/rss+xml" />
	<link>https://www.aitaocui.cn</link>
	<description>翡翠玉石爱好者聚集地</description>
	<lastBuildDate>Sun, 27 Nov 2022 03:27:39 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.1</generator>

<image>
	<url>https://www.aitaocui.cn/wp-content/uploads/2022/11/taocui.png</url>
	<title>Decimal</title>
	<link>https://www.aitaocui.cn</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Decimal(数据类型)</title>
		<link>https://www.aitaocui.cn/article/345350.html</link>
					<comments>https://www.aitaocui.cn/article/345350.html#respond</comments>
		
		<dc:creator><![CDATA[汁男]]></dc:creator>
		<pubDate>Sun, 27 Nov 2022 03:27:39 +0000</pubDate>
				<category><![CDATA[知识]]></category>
		<category><![CDATA[Decimal]]></category>
		<guid isPermaLink="false">https://www.aitaocui.cn/?p=345350</guid>

					<description><![CDATA[Decimal为SQL Server、MySql等数据库的一种数据类型，不属于浮点数类型，可以在定义时划定整数部份以及小数部分的位数。使用精确小数类型不仅能够保证数据计算更为精确，...]]></description>
										<content:encoded><![CDATA[</p>
<article>
<p>Decimal为SQL Server、MySql等数据库的一种数据类型，不属于浮点数类型，可以在定义时划定整数部份以及小数部分的位数。使用精确小数类型不仅能够保证数据计算更为精确，还可以节省储存空间，例如百分比使用decimal(,)即可。</p>
</article>
<article>
<h1>基本内容</h1>
<p>Decimal 数据类型Decimal 变量存储为 96 位（12 个字节）无符号的整型形式，并除以一个 10 的幂数。这个变比因子决定了小数点右面的数字位数，其范围从 0 到 28。变比因子为 0（没有小数位）的情形下，最大的可能值为+/-79,228,162,514,264,337,593,543,950,335。</p>
<p>而在有 28 个小数位的情况下，最大值为+/-7.9228162514264337593543950335，而最小的非零值为 +/-0.0000000000000000000000000001。注意此时，Decimal 数据类型只能在 Variant中使用，也就是说，不能声明一变量为 Decimal 的类型。不过可用 Cdec 函数，创建一个子类型为 Decimal 的 Variant。 这样就对了。Decimal类型消除了发生在各种浮点运算中的舍入误差,并可以准确地表示28个小数位。</p>
<p>Decimal数据类型可以在powerBuilder中使用。直接在编写控件的时候使用就可以了。比如：当编写一个Clicked事件脚本时就可以decimal r这样使用。</p>
<p>Decimal数据类型可以在Visual Studio编辑器中使用，只要在一个浮点类型的值后加一个大写或小写的M，则编辑器会认为这个浮点类型的值是一个Decimal类型。这种128位高精度十进制数表示法通常用在财务计算中。要注意的是，在.NET环境中，计算该类型的值会有性能上的损失，因为它不是基本类型。</p>
<p>固定有效位数和小数位数的数字。当使用最大有效位数时，有效值是从 &#8211; 10^38 +1 到 10^38 &#8211; 1。decimal 的 SQL-92 同义字是 dec 和 dec(p, s)。numeric 的功能相当于 decimal。</p>
<h1>位数简介</h1>
<p>p (有效位数)</p>
<p>可储存的最大十进位数总数，小数点左右两侧都包括在内。有效位数必须是 1 至最大有效位数 38 之间的值。预设有效位数是 18。</p>
<p>s (小数位数)</p>
<p>小数点右侧所能储存的最大十进位数。小数位数必须是从 0 到 p 的值。只有在指定了有效位数时，才能指定小数位数。预设小数位数是 0；因此，0 &lt;= s &lt;= p。最大储存体大小会随着有效位数而不同。</p>
<p>Decimal(n,m)表示数值中共有n位数，其中整数n-m位，小数m位。例：decimal(10,6)，数值中共有10位数，其中整数占4位，小数占6位。</p>
<p>例：decimal(2,1)，此时，插入数据“12.3”、“12”等会出现“数据溢出错误”的异常；插入“1.23”或“1.2345&#8230;”会自动四舍五成“1.2”；插入“2”会自动补成“2.0”，以确保2位的有效长度，其中包含1位小数。</p>
<p>当用int类型会有溢出时，可以用 decimal 类型进行处理，把结果可以用convert或是cast进行转换。</p>
</article>
<div class="mt-3 mb-3" style="max-width: 770px;height: auto;">
                                    </div>
<div class="mt-3 mb-3" style="max-width: 770px;height: auto;">
                                    </div>
<div class="mt-3 mb-3" style="max-width: 770px;height: auto;">
                                    </div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.aitaocui.cn/article/345350.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
