Re: NUMERIC private methods?

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, David Fetter <david(at)fetter(dot)org>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: NUMERIC private methods?
Date: 2015-03-22 04:00:40
Message-ID: 20150322040040.GI10795@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ Everyone has their own god. +

Attachment Content-Type Size
numeric.diff text/x-diff 1.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Gierth 2015-03-22 04:08:32 Re: NUMERIC private methods?
Previous Message Andrew Gierth 2015-03-22 03:28:01 debug_sortsupport GUC?