Re: NaN divided by zero should yield NaN

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: NaN divided by zero should yield NaN
Date: 2020-07-20 23:46:24
Message-ID: 767348.1595288784@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> writes:
> On Thu, 16 Jul 2020 at 20:29, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2020-07-21 02:06:32 Re: Wrong results from in_range() tests with infinite offset
Previous Message Justin Pryzby 2020-07-20 23:30:48 Re: expose parallel leader in CSV and log_line_prefix