Re: unsigned types - Mailing list pgsql-general

From Sim Zacks
Subject Re: unsigned types
Date
Msg-id 1726400907.20051016091827@compulab.co.il
Whole thread Raw
In response to unsigned types  (jeff sacksteder <jsacksteder@gmail.com>)
List 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 by date:

Previous
From: Sim Zacks
Date:
Subject: Re: strange error
Next
From: "Sim Zacks"
Date:
Subject: new type question