Re: PGSQL function for converting between arbitrary numeric bases?

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: PGSQL function for converting between arbitrary numeric bases?
Дата
Msg-id 20050819145935.GB11542@wolff.to
обсуждение исходный текст
Ответ на PGSQL function for converting between arbitrary numeric bases?  ("Simon Kinsella" <simon@bluefiresystems.co.uk>)
Список pgsql-sql
On Mon, Aug 15, 2005 at 16:48:40 +0100, Simon Kinsella <simon@bluefiresystems.co.uk> wrote:
> Hello,
> 
> I'm looking - without luck so far - for a PGSQL function for converting
> numbers between two arbitrary bases (typically base 10,16 and 26 in my
> case).  Something similar to the C 'strtol' function or, ideally, PHP's
> baseconvert(string,frombase,tobase) function.
> 
> I've search the docs, lists and various other forums but so far no luck.
> Just wondered if I've missed anything - all suggestions gratefully received.

I think you are looking at this wrong. You aren't really converting the
numbers. What base is used is only relevant during input and output.
You can write your own input and output functions based on the code used
for the standard input an output functions. There is already a to_hex
function that will convert an integer to text using hexadecimal notation.
For input from hex you might be able to use bit string constants
(e.g. x'10'::int).


В списке pgsql-sql по дате отправления:

Предыдущее
От: gherzig@fmed.uba.ar
Дата:
Сообщение: Re: [SOT] pypgsql function receiving dictionary as parameter?
Следующее
От: Halley Pacheco de Oliveira
Дата:
Сообщение: Re: SQL CASE Statements