Re: NaN divided by zero should yield NaN

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Andres Freund <andres@anarazel.de>
Date: 2020-07-20T23:46:24Z
Lists: pgsql-hackers
Dean Rasheed <dean.a.rasheed@gmail.com> writes:
> On Thu, 16 Jul 2020 at 20:29, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> One thing that's not very clear to me is which of these spellings
>> is preferable:
>> 	if (unlikely(val2 == 0.0) && !isnan(val1))
>> 	if (unlikely(val2 == 0.0 && !isnan(val1)))

> My guess is that the first would be better, since it would tell the
> compiler that it's unlikely to need to do the NaN test,

Yeah, that's the straightforward way to think about it, but I've
found that gcc is sometimes less than straightforward ;-).  Still,
there's no obvious reason to do it the second way, so I pushed the
first way.

			regards, tom lane



Commits

  1. Make floating-point "NaN / 0" return NaN instead of raising an error.