Re: unsigned types

Поиск
Список
Период
Сортировка
От Sim Zacks
Тема Re: unsigned types
Дата
Msg-id 1726400907.20051016091827@compulab.co.il
обсуждение исходный текст
Ответ на unsigned types  (jeff sacksteder <jsacksteder@gmail.com>)
Список pgsql-general
You can create a new type based on int2 called uint2.
he input function should subtract 32768 and the output function should
add 32768. The result should be an int4 so that a number such as 40000
can be displayed. The storage space required would still only be an
int2. The actual value stored in the database will be between -32768
to +32767 but the values that will be visible will be 0 to 65535

It seems simple enough to create a type to do that, though I haven't
tried.

Sim

>>You can use a signed type with a CHECK constraint to restrict the
>>column's value to positive integers.


>The sign doesn't concern me. I am storing a value that is unsigned
>and 16 bits wide natively. I'll have to just use an int4 and waste
>twice the space I actually need.


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

Предыдущее
От: Sim Zacks
Дата:
Сообщение: Re: strange error
Следующее
От: "Sim Zacks"
Дата:
Сообщение: new type question