hexadecimal values

Поиск
Список
Период
Сортировка
Искать

hexadecimal values

От:
Thierry Besancon <Thierry.Besancon@paris4.sorbonne.fr>
Дата:

        Hello 

Is there a means to enter directly hexadecimal number in an integer
field in a table ? (I don't known by advance if the number is hexa
ou decimal so I can't use a special function)

Best regards.

        Thierry       

Re: hexadecimal values

От:
Jeff Davis <list-pgsql-general@empires.org>
Дата:
What do you mean you won't know in advance? If not, how do you tell the 
difference between 10 hexadecimal (which is 16) and 10 decimal (which is 10)?

Have you considered just having your application convert it first? There may 
be a postgresql function to convert it as well, however I couldn't find it 
offhand. You could also create your own stored procedure.

Regards,
	Jeff

On Thursday 02 May 2002 04:28 am, Thierry Besancon wrote:
>         Hello
>
> Is there a means to enter directly hexadecimal number in an integer
> field in a table ? (I don't known by advance if the number is hexa
> ou decimal so I can't use a special function)
>
> Best regards.
>
>         Thierry
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

Re: hexadecimal values

От:
Jeff Davis <list-pgsql-general@empires.org>
Дата:
Oh, that makes more sense. I don't think that there is an internal postgres 
stored procedure for doing that, but I can't imagine it would be that hard to 
write one.

I suppose that someone could add the ability to parse hex values in the text 
to int converter. Is that what you'd like to see? that way you could do:

select '0x10'::int;
or:
select '10'::int; 

and they would return 16 and 10 respectively.

It also should be quite easy to do the conversion in your application before 
sending it to the database. Look at the C function strtol().

Regards,
	Jeff

On Thursday 02 May 2002 03:06 pm, Thierry Besancon wrote:
> >> What do you mean you won't know in advance? If not, how do you tell the
> >> difference between 10 hexadecimal (which is 16) and 10 decimal (which is
> >> 10) ?
>
> I mean the user can input 0x10 or 010 or 10 and I want the C way of dealing
> with these numbers.
>
> 	Thierry
FAQ