Re: Infinity vs Error for division by zero
От | Chapman Flack |
---|---|
Тема | Re: Infinity vs Error for division by zero |
Дата | |
Msg-id | 6afe6a89-8809-5196-36f4-0ad2e4685e77@anastigmatix.net обсуждение исходный текст |
Ответ на | Re: Infinity vs Error for division by zero ("David G. Johnston" <david.g.johnston@gmail.com>) |
Ответы |
Re: Infinity vs Error for division by zero
|
Список | 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
В списке pgsql-hackers по дате отправления: