| From: | Chapman Flack <chap(at)anastigmatix(dot)net> |
|---|---|
| To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Matt Pulver <mpulver(at)unitytechgroup(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Infinity vs Error for division by zero |
| Date: | 2019-03-01 18:23:54 |
| Message-ID: | 6afe6a89-8809-5196-36f4-0ad2e4685e77@anastigmatix.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 3/1/19 1:04 PM, David G. Johnston wrote:
> 1/0 is an illegal operation. We could return NaN for it but the choice of
> throwing an error is just as correct. Returning infinity is strictly
> incorrect.
That differs from my understanding of how the operations are specified
in IEEE 754 (as summarized in, e.g., [1]).
Andrew posted the relevant part of the SQL spec that requires the
operation to raise 22012.
That's a requirement specific to SQL (which is, of course, what matters
here.)
But if someone wanted to write a user-defined division function or
operator that would return Inf for (anything > 0) / 0 and for
(anything < 0) / -0, and -Inf for (anything < 0) / 0 and for
(anything > 0) / -0, and NaN for (either zero) / (either zero), I think
that function or operator would be fully in keeping with IEEE 754.
-Chap
[1] https://steve.hollasch.net/cgindex/coding/ieeefloat.html#operations
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andres Freund | 2019-03-01 18:26:05 | Re: Infinity vs Error for division by zero |
| Previous Message | Adrien NAYRAT | 2019-03-01 18:17:47 | Re: Log a sample of transactions |