From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Gregory Stark <stark(at)enterprisedb(dot)com> |
Cc: | "Michael Paesold" <mpaesold(at)gmx(dot)at>, "Bruce Momjian" <bruce(at)momjian(dot)us>, pgsql-patches(at)postgresql(dot)org |
Subject: | Re: WIP: rewrite numeric division |
Date: | 2007-07-17 18:15:13 |
Message-ID: | 3829.1184696113@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-patches |
Gregory Stark <stark(at)enterprisedb(dot)com> writes:
> "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
>> Well, this doesn't take a lot of numerical methods background: the
>> fundamental problem is that the existing code generates an *approximate*
>> answer, whereas people who are doing div and mod on large integers tend
>> to expect an *exact* answer. Approximate doesn't cut it --- there will
>> always be cases where an off-by-one-in-the-last-internal-place error can
>> carry far enough to the left to be visible to the user.
> So does your code behave differently for this or does it round off to the
> arbitrary division precision before hitting trunc?
> postgres=# select trunc(99999999999999999999::numeric / 1000000000::numeric);
> trunc
> --------------
> 100000000000
> (1 row)
No, my proposed patch doesn't change that. It might be that we should
provide an "integer division" operator for NUMERIC, so that you can get
at the exact result of trunc(x/y).
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Simon Riggs | 2007-07-17 18:31:15 | Re: Async Commit, v21 (now: v22) |
Previous Message | Magnus Hagander | 2007-07-17 18:07:36 | Re: [HACKERS] msvc, build and install with cygwin in the PATH |