Re: unsafe floats - Mailing list pgsql-hackers

From Tom Lane
Subject Re: unsafe floats
Date
Msg-id 2394.1079044734@sss.pgh.pa.us
Whole thread Raw
In response to Re: unsafe floats  (Dennis Bjorklund <db@zigo.dhs.org>)
List pgsql-hackers
Dennis Bjorklund <db@zigo.dhs.org> writes:
> On Thu, 11 Mar 2004, Neil Conway wrote:
>> So, what is the correct behavior: if you multiply two values and get a
>> result that exceeds the range of a float8, should you get
>> 'Infinity'/'-Infinity', or an overflow error?

> That's the issue and I think we should allow infinity as a result of a 
> float operation (like you got in the example). It's part of IEEE 754 
> math, so not getting Infinity as a result would break that.

This would still be infinitely (ahem) better than the behavior you get
when an integer operation overflows.  We return whatever the hardware
gives in such cases.  Returning whatever the hardware gives for a float
overflow doesn't seem out of line, particularly if it's a well-defined
behavior.

I am somewhat concerned about the prospect of implementation-dependent
results --- machines that do not implement IEEE-style math are going to
return something other than an Infinity.  However, I think that
providing access to the IEEE semantics is more useful than a (rather
vain) attempt to impose uniformity across IEEE and non-IEEE machines.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Sailesh Krishnamurthy
Date:
Subject: Re: Performance and WAL on big inserts/updates
Next
From: Robert Treat
Date:
Subject: Re: Default Stats Revisited