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

From Tom Lane
Subject Re: BUG #15519: Casting float4 into int4 gets the wrong sign instead of "integer out of range" error
Date
Msg-id 15332.1543017494@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #15519: Casting float4 into int4 gets the wrong sign instead of "integer out of range" error  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
I wrote:
> Andrew Gierth <andrew@tao11.riddles.org.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


pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #15519: Casting float4 into int4 gets the wrong sign instead of "integer out of range" error
Next
From: Andrew Gierth
Date:
Subject: Re: BUG #15519: Casting float4 into int4 gets the wrong sign instead of "integer out of range" error