From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: victor@magic.io
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15519: Casting float4 into int4 gets the wrong sign instead of "integer out of range" error
Date: Sat, 24 Nov 2018 00:45:38 +0000
Message-ID: <87va4nqr1a.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <15115.1543017152@sss.pgh.pa.us>
References: <15519-4fc785b483201ff1@postgresql.org>
<874lc7sb1a.fsf@news-spur.riddles.org.uk>
<13162.1543014227@sss.pgh.pa.us>
<87zhtzqs9o.fsf@news-spur.riddles.org.uk>
<15115.1543017152@sss.pgh.pa.us>
>>>>> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> writes:
Tom> if (unlikely(num < (float4) INT_MIN || num >= (float4) INT_MAX || isnan(num)))
>> if (num < (float4)INT_MIN || num >= -(float4)INT_MIN || ...
Tom> Meh. Seems to me that's relying on pretty much the same
Tom> assumptions
No, because we know that INT_MIN is always exactly representable as a
float (whereas INT_MAX is not), and therefore the cast result will not
depend on any rounding choices whether at compile or run time. Nor does
it depend on knowing that float4 can't represent INT_MAX exactly.
--
Andrew (irc:RhodiumToad)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: andrew@tao11.riddles.org.uk, tgl@sss.pgh.pa.us, victor@magic.io, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15519: Casting float4 into int4 gets the wrong sign instead of "integer out of range" error
In-Reply-To: <87va4nqr1a.fsf@news-spur.riddles.org.uk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox