Number(p,s)的使用

來源:互聯網
上載者:User

轉自:http://blog.itpub.net/post/26/3796

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

p>0,對s分2種情況分析:

1. s>0
精確到小數點右邊s位,並四捨五入。然後檢驗有效數位是否<=p;如果s>p,小數點右邊至少有s-p個0填充。

2. s<0
精確到小數點左邊s位,並四捨五入。然後檢驗有效數位是否<=p+|s|

(有效數位:從左邊第一個不為0的數算起)

PS:SQL Service中預設精度是(18,0)。

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)

Error

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.