8
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PostgreSQLで基数変換

Posted at

10進数 → 2進数

SELECT 33::bit(16);
       bit        
------------------
 0000000000100001
(1 row)

2進数 → 10進数

SELECT '0000000000100001'::bit(16)::int;
 int4 
------
   33
(1 row)

10進数 → 16進数

SELECT to_hex(33);
 to_hex 
--------
 21
(1 row)

16進数 → 10進数

SELECT 'x0021'::bit(16)::int;
 int4 
------
   33
(1 row)
8
6
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?