Re: Divid by zero bug in float - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Divid by zero bug in float
Date
Msg-id 13354.1140630011@sss.pgh.pa.us
Whole thread Raw
In response to Divid by zero bug in float  ("Jim C. Nasby" <jnasby@pervasive.com>)
Responses Re: Divid by zero bug in float
List pgsql-hackers
"Jim C. Nasby" <jnasby@pervasive.com> writes:
> Shouldn't this produce Infinity instead of an error?
> postgresql=# select 5::float/0::float;
> ERROR:  division by zero

No, I don't think so.  SQL92 6.12 <numeric value expression> quoth:
        4) The dyadic arithmetic operators <plus sign>, <minus sign>, <as-           terisk>, and <solidus> (+, -, *,
and/, respectively) specify           addition, subtraction, multiplication, and division, respec-           tively. If
thevalue of a divisor is zero, then an exception           condition is raised: data exception-division by zero.
 

There is nothing in there about allowing IEEE infinities instead, and
I very strongly doubt that the average database user would expect such
behavior.
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: Divid by zero bug in float
Next
From: "Jim C. Nasby"
Date:
Subject: Re: Divid by zero bug in float