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:58:14
Message-ID: 15332.1543017494@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I wrote:
> Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> writes:
>> 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.

mmm ... but on the other hand, it means we don't need to write the
test differently depending on whether we think INTxx_MAX will get
rounded. So that's worth something.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrew Gierth 2018-11-24 00:45:38 Re: BUG #15519: Casting float4 into int4 gets the wrong sign instead of "integer out of range" error
Previous Message Tom Lane 2018-11-23 23:52:32 Re: BUG #15519: Casting float4 into int4 gets the wrong sign instead of "integer out of range" error