Re: fix integer datetime division rounding error

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: "Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org>, RoccoA(at)Routescape(dot)com
Subject: Re: fix integer datetime division rounding error
Date: 2005-07-24 04:37:08
Message-ID: 200507240437.j6O4b8k02587@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Andrew Dunstan wrote:
>
> The attached patch seems to fix the rounding error that is causing
> regression failures on machines with integer datetimes. (Source of error
> discovered by Andrew(at)Supernews).ISTM this code needs to be given some
> careful analysis - I know it makes my head spin reading it.

Ah, brilliant! I knew I was missing something fundamental, and the use
of rint() was it. Strangely enough, the 8.0 code uses rint() in that
function, but for floating point intervals, and the code was buggy,
generating negative time values for division.

Patch attached and applied. I also improved the interval multiplication
code.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 4.0 KB

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Rocco Altier 2005-07-24 05:41:47 Re: fix integer datetime division rounding error
Previous Message Tom Lane 2005-07-24 02:38:59 Re: [HACKERS] Patch to fix plpython on OS X