Re: Help with converting hexadecimal to decimal

From: Doug Quale <quale1(at)charter(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Help with converting hexadecimal to decimal
Date: 2005-04-01 03:22:12
Message-ID: 87sm2bqizf.fsf@charter.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:

> Chandra Sekhar Surapaneni wrote:
> > Hi All,
> > Is there a built in function which works exactly the opposite way as
> > to_hex().
> > I basically want to convert a a hexadecimal to a decimal.
>
> Sure:
>
> test=> SELECT x'10'::integer;
> int4
> ------
> 16
> (1 row)

That's not the inverse of to_hex(). to_hex() takes an integer and
returns text. You've taken the bitstring constant B'10000' and
coerced it to integer. The inverse funtion would take the text '10'
and return the integer 16.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Zitan Broth 2005-04-01 03:22:58 SELECT INTO Array?
Previous Message Glen Eustace 2005-04-01 02:51:52 Inconsistent values for 'now'