pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: gkokolatos@pm.me
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: Strange behavior with polygon and NaN
Date: Fri, 13 Nov 2020 11:26:21 -0500
Message-ID: <289049.1605284781@sss.pgh.pa.us> (raw)
In-Reply-To: <20201113.153558.1784247402374030454.horikyota.ntt@gmail.com>
References: <20201105.140732.2068435975647079587.horikyota.ntt@gmail.com>
	<YP74y35GS9uaMLpKm0BiA_eK6etwydDvLfty44ykXV_cY74D9joc1H1xOI27Bq5L6YHwEV7huDY43hwbXu5i6RWK9vL53TgsbUtdVD26cP0=@pm.me>
	<2200966.1605036608@sss.pgh.pa.us>
	<20201113.153558.1784247402374030454.horikyota.ntt@gmail.com>

Kyotaro Horiguchi <horikyota.ntt@gmail.com> writes:
> At Tue, 10 Nov 2020 14:30:08 -0500, Tom Lane <tgl@sss.pgh.pa.us> wrote in 
>> For instance, {1,-1,0} is the line "x = y".  We could argue about
>> whether it'd be sensible to return zero for the distance between that
>> and the point (inf,inf), but surely any point with one inf and one
>> finite coordinate must be an infinite distance away from that line.
>> There's nothing ill-defined about that situation.

> Mmm... (swinging my arms to mimic lines..)
> dist(x = y, (1e300, Inf)) looks indeterminant to me..

Well, what you're showing is that we get an internal overflow,
essentially, on the way to calculating the result.  Which is true,
so it's sort of accidental that we got a sensible result before.
Nonetheless, we *did* get a sensible result, so producing NaN
instead seems like a regression.

We might need to introduce special-case handling to protect the
low-level calculations from ever seeing NaN or Inf in their inputs.
Getting the right answer to "just fall out" of those calculations
might be an unreasonable hope.

For example, for a line with positive slope (A and B of opposite
signs), I think that the right answer for points (Inf,Inf) and
(-Inf,-Inf) should be NaN, on much the same grounds that Inf
minus Inf is NaN not zero.  But all other points involving any Inf
coordinates are clearly an infinite distance away from that line.

			regards, tom lane





view thread (30+ messages)  latest in thread

Message-ID: <289049.1605284781@sss.pgh.pa.us>
Permalink:  ../289049.1605284781@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/289049.1605284781@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, horikyota.ntt@gmail.com, gkokolatos@pm.me, pgsql-hackers@lists.postgresql.org
  Subject: Re: Strange behavior with polygon and NaN
  In-Reply-To: <289049.1605284781@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox