Re: Help with converting hexadecimal to decimal - Mailing list pgsql-general

From Doug Quale
Subject Re: Help with converting hexadecimal to decimal
Date
Msg-id 87sm2bqizf.fsf@charter.net
Whole thread Raw
In response to Re: Help with converting hexadecimal to decimal  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: Help with converting hexadecimal to decimal  (Dawid Kuroczko <qnex42@gmail.com>)
List pgsql-general
Bruce Momjian <pgman@candle.pha.pa.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.

pgsql-general by date:

Previous
From: Glen Eustace
Date:
Subject: Inconsistent values for 'now'
Next
From: "Zitan Broth"
Date:
Subject: SELECT INTO Array?