On Thu, 2 May 2024 at 23:25, Hans Buschmann <buschmann(at)nidsa(dot)net> wrote:
> postgres=# select -32768::smallint;
> ERROR: smallint out of range
The precedence order of operations applies the cast before the unary
minus operator.
Any of the following will work:
postgres=# select cast(-32768 as smallint), (-32768)::smallint,
'-32768'::smallint;
int2 | int2 | int2
--------+--------+--------
-32768 | -32768 | -32768
(1 row)
David