Oracle concept 学习 1---精度和 维度

原文:

Precision
The precision specifies the total number of digits. If a precision is not specified, then the column stores the values exactly as provided by the application without any rounding.
Scale
The scale specifies the number of digits from the decimal point to the least significant digit. Positive scale counts digits to the right of the decimal point up to and including the least significant digit. Negative scale counts digits to the left of the decimal point up to but not including the least significant digit. If you specify a precision without a scale, as in NUMBER(6), then the scale is 0.

number(p,s) p:1~38  s:-84~127
P可以理解为有效数位 :从左边第一个不为 0 的数算起,到末位数字为止的所有数字,小数点和负号不计入有效位数。
S为从哪一位开始进行四舍五入


number(p,s) p:1~38  s:-84~127

最高整数位数=p-s

s正数,小数点右边指定位置开始四舍五入

s负数,小数点左边指定位置开始四舍五入

s0或者未指定,四舍五入到最近整数

p小于s时候,表示数字是绝对值小于1的数字,且从小数点右边开始的前s-p 位必须是0,保留s位小数。

p>0,对s2种情况:

1. s>0

精确到小数点右边s位,并四舍五入。然后检验有效数位是否<=p;如果s>p,小数点右边至少有s-p0填充。

2. s<0

精确到小数点左边s位,并四舍五入。然后检验有效数位是否<=p+|s|


比如

Value        Datatype     Stored Value

123.2564     NUMBER          123.2564

1234.9876    NUMBER(6,2)     1234.99

12345.12345  NUMBER(6,2)     Error

1234.9876    NUMBER(6)       1235

12345.345    NUMBER(5,-2)    12300

1234567      NUMBER(5,-2)    1234600

12345678     NUMBER(5,-2)    Error

123456789    NUMBER(5,-4)    123460000

1234567890   NUMBER(5,-4)    Error

12345.58     NUMBER(*, 1)    12345.6

0.1          NUMBER(4,5)     Error

0.01234567   NUMBER(4,5)     0.01235

0.09999      NUMBER(4,5)     0.09999

0.099996     NUMBER(4,5)     <>

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28826508/viewspace-1369274/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/28826508/viewspace-1369274/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值