From: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
---|---|
To: | Aleksander Alekseev <aleksander(at)timescale(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: to_hex() for negative inputs |
Date: | 2023-01-25 11:21:11 |
Message-ID: | CAEZATCV7Gi08adZamHcL5Uy2MPqwbGGsz6E5he-_NeeXw4nhPg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, 25 Jan 2023 at 10:57, Aleksander Alekseev
<aleksander(at)timescale(dot)com> wrote:
>
> > Of course there is. This is easy to code in C using unsigned ints,
> > without resorting to abs() (yes, I'm aware that abs() is undefined for
> > INT_MIN).
>
> So in your opinion what is the expected result of to_hex(INT_MIN,
> with_sign => true)?
>
"-80000000" or "-0x80000000", depending on whether the prefix is
requested. The latter is legal input for an integer, which is the
point (to allow round-tripping):
SELECT int '-0x80000000';
int4
-------------
-2147483648
(1 row)
SELECT pg_typeof(-0x80000000);
pg_typeof
-----------
integer
(1 row)
Regards,
Dean
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Kapila | 2023-01-25 11:25:57 | Re: Logical replication timeout problem |
Previous Message | Hayato Kuroda (Fujitsu) | 2023-01-25 11:07:16 | RE: [Proposal] Add foreign-server health checks infrastructure |