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

Поиск
Список
Период
Сортировка
От Andrew Gierth
Тема Re: BUG #15519: Casting float4 into int4 gets the wrong sign instead of "integer out of range" error
Дата
Msg-id 87va4nqr1a.fsf@news-spur.riddles.org.uk
обсуждение исходный текст
Ответ на 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>)
Ответы Re: BUG #15519: Casting float4 into int4 gets the wrong sign insteadof "integer out of range" error  (Victor Petrovykh <victor@magic.io>)
Список pgsql-bugs
>>>>> "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)


В списке pgsql-bugs по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #15519: Casting float4 into int4 gets the wrong sign instead of "integer out of range" error
Следующее
От: Victor Petrovykh
Дата:
Сообщение: Re: BUG #15519: Casting float4 into int4 gets the wrong sign insteadof "integer out of range" error