Re: BUG #15519: Casting float4 into int4 gets the wrong sign instead of "integer out of range" error

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
Cc: victor(at)magic(dot)io, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15519: Casting float4 into int4 gets the wrong sign instead of "integer out of range" error
Date: 2018-11-23 23:52:32
Message-ID: 15115.1543017152@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> writes:
> "Tom" == Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
> Tom> if (unlikely(num < (float4) INT_MIN || num >= (float4) INT_MAX || isnan(num)))

> if (num < (float4)INT_MIN || num >= -(float4)INT_MIN || ...

Meh. Seems to me that's relying on pretty much the same assumptions
and throwing in an extra dollop of obscurantism on top.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2018-11-23 23:58:14 Re: BUG #15519: Casting float4 into int4 gets the wrong sign instead of "integer out of range" error
Previous Message Andrew Gierth 2018-11-23 23:42:50 Re: BUG #15519: Casting float4 into int4 gets the wrong sign instead of "integer out of range" error