【進位制轉換】十進位制與十六進位制相互轉換方法
Oracle提供的to_char和to_number函式在進位制轉換上也有貢獻。簡單演示一下。
1.使用TO_CHAR函式將十進位制數轉換為十六進位制數的方法和效果如下
sec@ora10g> select TO_CHAR (1, 'XX') as "1",
2 TO_CHAR (2, 'XX') as "2",
3 TO_CHAR (3, 'XX') as "3",
4 TO_CHAR (4, 'XX') as "4",
5 TO_CHAR (5, 'XX') as "5",
6 TO_CHAR (6, 'XX') as "6",
7 TO_CHAR (7, 'XX') as "7",
8 TO_CHAR (8, 'XX') as "8",
9 TO_CHAR (9, 'XX') as "9",
10 TO_CHAR (10, 'XX') as "10",
11 TO_CHAR (11, 'XX') as "11",
12 TO_CHAR (12, 'XX') as "12",
13 TO_CHAR (13, 'XX') as "13",
14 TO_CHAR (14, 'XX') as "14",
15 TO_CHAR (15, 'XX') as "15",
16 TO_CHAR (16, 'XX') as "16",
17 TO_CHAR (17, 'XX') as "17"
18 from DUAL;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
1 2 3 4 5 6 7 8 9 A B C D E F 10 11
2.反過來,使用TO_NUMBER函式將十六進位制數轉換為十進位制數的方法和效果如下
sec@ora10g> select TO_NUMBER ('1', 'XX') as "1",
2 TO_NUMBER ('2', 'XX') as "2",
3 TO_NUMBER ('3', 'XX') as "3",
4 TO_NUMBER ('4', 'XX') as "4",
5 TO_NUMBER ('5', 'XX') as "5",
6 TO_NUMBER ('6', 'XX') as "6",
7 TO_NUMBER ('7', 'XX') as "7",
8 TO_NUMBER ('8', 'XX') as "8",
9 TO_NUMBER ('9', 'XX') as "9",
10 TO_NUMBER ('A', 'XX') as "A",
11 TO_NUMBER ('B', 'XX') as "B",
12 TO_NUMBER ('C', 'XX') as "C",
13 TO_NUMBER ('D', 'XX') as "D",
14 TO_NUMBER ('E', 'XX') as "E",
15 TO_NUMBER ('F', 'XX') as "F",
16 TO_NUMBER ('10', 'XX') as "10",
17 TO_NUMBER ('11', 'XX') as "11"
18 from DUAL;
1 2 3 4 5 6 7 8 9 A B C D E F 10 11
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
演示完畢。
-- The End --
1.使用TO_CHAR函式將十進位制數轉換為十六進位制數的方法和效果如下
sec@ora10g> select TO_CHAR (1, 'XX') as "1",
2 TO_CHAR (2, 'XX') as "2",
3 TO_CHAR (3, 'XX') as "3",
4 TO_CHAR (4, 'XX') as "4",
5 TO_CHAR (5, 'XX') as "5",
6 TO_CHAR (6, 'XX') as "6",
7 TO_CHAR (7, 'XX') as "7",
8 TO_CHAR (8, 'XX') as "8",
9 TO_CHAR (9, 'XX') as "9",
10 TO_CHAR (10, 'XX') as "10",
11 TO_CHAR (11, 'XX') as "11",
12 TO_CHAR (12, 'XX') as "12",
13 TO_CHAR (13, 'XX') as "13",
14 TO_CHAR (14, 'XX') as "14",
15 TO_CHAR (15, 'XX') as "15",
16 TO_CHAR (16, 'XX') as "16",
17 TO_CHAR (17, 'XX') as "17"
18 from DUAL;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
1 2 3 4 5 6 7 8 9 A B C D E F 10 11
2.反過來,使用TO_NUMBER函式將十六進位制數轉換為十進位制數的方法和效果如下
sec@ora10g> select TO_NUMBER ('1', 'XX') as "1",
2 TO_NUMBER ('2', 'XX') as "2",
3 TO_NUMBER ('3', 'XX') as "3",
4 TO_NUMBER ('4', 'XX') as "4",
5 TO_NUMBER ('5', 'XX') as "5",
6 TO_NUMBER ('6', 'XX') as "6",
7 TO_NUMBER ('7', 'XX') as "7",
8 TO_NUMBER ('8', 'XX') as "8",
9 TO_NUMBER ('9', 'XX') as "9",
10 TO_NUMBER ('A', 'XX') as "A",
11 TO_NUMBER ('B', 'XX') as "B",
12 TO_NUMBER ('C', 'XX') as "C",
13 TO_NUMBER ('D', 'XX') as "D",
14 TO_NUMBER ('E', 'XX') as "E",
15 TO_NUMBER ('F', 'XX') as "F",
16 TO_NUMBER ('10', 'XX') as "10",
17 TO_NUMBER ('11', 'XX') as "11"
18 from DUAL;
1 2 3 4 5 6 7 8 9 A B C D E F 10 11
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
演示完畢。
-- The End --
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/519536/viewspace-620447/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 二進位制,八進位制,十進位制,十六進位制的相互轉換
- Qt進位制轉換(十進位制轉十六進位制)QT
- (轉)【iOS 開發】二進位制、十進位制、十六進位制相互轉換的方法iOS
- JAVA 二進位制,八進位制,十六進位制,十進位制間進行相互轉換Java
- 十六進位制轉換為十進位制
- 二進位制、十進位制與十六進位制相互轉化
- Oracle中的二進位制、八進位制、十進位制、十六進位制相互轉換函式Oracle函式
- 【轉帖】Oracle中的二進位制、八進位制、十進位制、十六進位制相互轉換函式Oracle函式
- Oracle中十進位制與十六進位制轉換程式Oracle
- 進位制之間的轉換之“十六進位制 轉 十進位制 轉 二進位制 方案”
- java中二進位制、八進位制、十進位制、十六進位制的轉換Java
- 二進位制,八進位制,十進位制,十六進位制之間的轉換
- Python 進位制互相轉換(二進位制、十進位制和十六進位制)Python
- 【進位制轉換】二進位制、十六進位制、十進位制、八進位制對應關係
- 計算機基礎進位制轉換(二進位制、八進位制、十進位制、十六進位制)計算機
- 十進位制轉十六進位制
- 十六進位制轉換為八進位制
- 二進位制轉十進位制快速轉換方法
- 大話二進位制,八進位制,十進位制,十六進位制之間的轉換
- Oracle二進位制與十進位制轉換Oracle
- 一看就懂二進位制、八進位制、十六進位制數轉換十進位制
- python進位制轉換(二進位制、十進位制和十六進位制)及注意事項Python
- 十六進位制數轉十進位制
- javascript十進位制數字和二進位制相互轉換JavaScript
- [計算機基礎] 計算機進位制轉換:二進位制、八進位制、十進位制、十六進位制計算機
- 十進位制與二進位制互相轉換指南
- 進位制數轉換方法(八/十六/十)
- ORACLE使用函式對二進位制、十進位制、十六進位制數互相轉換Oracle函式
- JavaScript 進位制轉換(2進位制、8進位制、10進位制、16進位制之間的轉換)JavaScript
- JavaScript十進位制轉換為二進位制JavaScript
- js實現的十進位制和十六進位制相互轉換程式碼例項JS
- 十進位制轉換為十六進位制和二進位制程式碼例項
- 遞迴-進位制轉換器(十六進位制以內)遞迴
- [MSSQL]將十進位制轉成十六進位制SQL
- 遞迴函式實現十進位制正整數轉換為二進位制,八進位制,十六進位制遞迴函式
- oracle 給的轉換函式實現 十六進位制---->十進位制Oracle函式
- 十進位制轉換任意進位制--鏈棧實現
- JavaScript 二進位制數字轉換為十進位制JavaScript