On Thu, Dec 18, 2014 at 11:51:12PM -0500, Tom Lane wrote:
> If you're doing any sort of higher math or statistics, I stand by my
> statement that you'd better think rather than just blindly assume that
> numeric is going to be better for you. A moment's fooling about finds
> this example, which is pretty relevant to the formula we started this
> thread with:
>
> regression=# select (1234::numeric/1235) * 1235;
> ?column?
> ---------------------------
> 1234.00000000000000000100
> (1 row)
>
> regression=# select (1234::float8/1235) * 1235;
> ?column?
> ----------
> 1234
> (1 row)
>
> What it boils down to is that numeric is great for storing given decimal
> inputs exactly, and it can do exact addition/subtraction/multiplication
> on those too, but as soon as you get into territory where the result is
> fundamentally inexact it is *not* promised to be better than float8.
> In fact, it's designed to be more or less the same as float8; see the
> comments in select_div_scale.
Based on the analysis above, I have written the attached patch to the
NUMERIC docs to mention this.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ Everyone has their own god. +