Base Conversion Routines

This set of routines is useful to convert between various 'bases' in Oracle. Once you install these functions, you will be able to perform operations such as:

SQL> select to_bin( 123 ) bin, to_hex( 123 ) hex, to_oct( 123 ) oct from dual
  2  /

BIN             HEX             OCT
--------------- --------------- ---------------
1111011         7B              173

SQL> 
SQL> select to_dec( '1111011', 2 ) base2, to_dec( '7B' ) base16,
  2         to_dec('173',8) base8
  3    from dual
  4  /

     BASE2     BASE16      BASE8
---------- ---------- ----------
       123        123        123

 

You may download the source for these routines here.


All information and materials provided here are provided "as-is"; Oracle disclaims all express and implied warranties, including, the implied warranties of merchantability or fitness for a particular use. Oracle shall not be liable for any damages, including, direct, indirect, incidental, special or consequential damages for loss of profits, revenue, data or data use, incurred by you or any third party in connection with the use of this information or these materials.