Decimal、Numeric And Money

数字类型和货币类型

 

1.    数字数据... 1

1.1.     整型数据... 1

1.2.     小数数据... 1

1.3.     近似数字数据... 2

2.    货币数据... 2

 

1.   数字数据

    数字数据只包含数字。数字数据包括正数、负数、小数、分数和整数。

1.1. 整型数据

整型数据由负整数或正整数组成, -1505 2509

Microsoft  SQL Server  2000 ,整型数据使用 bigintintsmallint tinyint 数据类型存储。bigint 数据类型可存储的数字范围比 int 数据类型广。int 数据类型比 smallint 数据类型的存储范围大, smallint 的数值范围又比 tinyint 类型大。

    bigint 数据类型存储从 -2^63 (-9223372036854775808) 2^63-1 (9223372036854775807) 范围内的数字。存储大小为 8 个字节。

    int 数据类型的存储范围是 -2,147,483,648 2,147,483,647(每个值需 4 个字节的存储空间)

smallint 数据类型的存储范围只有 -32,768 32,767(每个值需 2 个字节的存储空间)

tinyint 数据类型只能存储 0 255 范围内的数字(每个值需 1 个字节的存储空间)

1.2. 小数数据

Decimal 数据包含存储在最小有效数上的数据。

SQL Server,小数数据使用 decimal numeric 数据类型存储。存储 decimal numeric 数值所需的字节数取决于该数据的数字总数和小数点右边的小数位数。例如,存储数值 19283.29383 比存储 1.1 需要更多的字节。

SQL Server,numeric 数据类型等价于 decimal 数据类型。

 

    decimal numeric详解】

    带定点精度和小数位数的 numeric 数据类型。

    decimal[(p[, s])] numeric[(p[, s])]

    定点精度和小数位数。使用最大精度时,有效值从 - 10^38 +1 10^38 - 1decimal SQL-92 同义词是 dec dec(p, s)

    p(精度)

    指定小数点左边和右边可以存储的十进制数字的最大个数。精度必须是从 1 到最大精度之间的值。最大精度为 38

    s(小数位数)

    指定小数点右边可以存储的十进制数字的最大个数。小数位数必须是从 0 p 之间的值。默认小数位数是 0,因而 0 <= s <= p。最大存储大小基于精度而变化。

    精度 存储字节数

    1 - 9 5

    10-19 9

    20-28 13

    29-38 17

1.3. 近似数字数据

    近似数字(浮点)数据包括按二进制计数系统所能提供的最大精度保留的数据。在 SQL Server ,近似数字数据以 float real 数据类型存储。例如,分数 1/3 表示成小数形式为 0.333333(循环小数),该数字不能以近似小数数据精确表示。因此, SQL Server 获取的值可能并不准确代表存储在列中的原始数据。又如, .3, .6, .7 结尾的浮点数均为数字近似值。

2.   货币数据

货币数据表示正的或负的货币值。

Microsoft SQL Server 2000 中使用 money smallmoney 数据类型存储货币数据。货币数据存储的精确度为四位小数。

可以存储在 money 数据类型中的值的范围是 -922,337,203,685,477.5808 +922,337,203,685,477.5807( 8 个字节的存储空间)

可以存储在 smallmoney 数据类型中的值的范围是 -214,748.3648 214,748.3647( 4 个字节的存储空间)。如果数值超过了上述范围,则可使用 decimal 数据类型代替。

 

    money smallmoney详解】

    代表货币或现金值的货币数据类型。

    money

    货币数据值介于 -2^63 (-922,337,203,685,477.5808) 2^63 - 1 (+922,337,203,685,477.5807) 之间,精确到货币单位的千分之十。存储大小为 8 个字节。

    smallmoney

    货币数据值介于 -214,748.3648 +214.748,3647 之间,精确到货币单位的千分之十。存储大小为 4 个字节。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
用c++解决You surely know that there are N different currencies you can deal with in our city. Let us assign unique integer number from 1 to N to each currency. Then each exchange point can be described with 6 numbers: integer A and B - numbers of currencies it exchanges, and real RAB, CAB, RBA and CBA - exchange rates and commissions when exchanging A to B and B to A respectively. Nick has some money in currency S and wonders if he can somehow, after some exchange operations, increase his capital. Of course, he wants to have his money in currency S in the end. Help him to answer this difficult question. Nick must always have non-negative sum of money while making his operations. Input The first line contains four numbers: N - the number of currencies, M - the number of exchange points, S - the number of currency Nick has and V - the quantity of currency units he has. The following M lines contain 6 numbers each - the description of the corresponding exchange point - in specified above order. Numbers are separated by one or more spaces. 1 ≤ S ≤ N ≤ 100, 1 ≤ M ≤ 100, V is real number, 0 ≤ V ≤ 103. For each point exchange rates and commissions are real, given with at most two digits after the decimal point, 10-2 ≤ rate ≤ 102, 0 ≤ commission ≤ 102. Let us call some sequence of the exchange operations simple if no exchange point is used more than once in this sequence. You may assume that ratio of the numeric values of the sums at the end and at the beginning of any simple sequence of the exchange operations will be less than 104. Output If Nick can increase his wealth, output YES, in other case output NO.
最新发布
06-03

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值