Skip site navigation (1) Skip section navigation (2)

Re: Arbitrary precision modulo operation

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Paul Tillotson <pntil(at)shentel(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: Arbitrary precision modulo operation
Date: 2004-04-28 07:04:43
Message-ID: 20040428070443.GC6901@wolff.to (view raw or flat)
Thread:
Lists: pgsql-general
On Wed, Apr 28, 2004 at 02:01:00 -0400,
  Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Paul Tillotson <pntil(at)shentel(dot)net> writes:
> > mod(x, y) is computed as x - trunc(x / y) * y in the mod_var() function 
>  
> It could be that select_div_scale needs to allow some more slop, or that
> that routine is okay but mod_var shouldn't depend on it to select the
> intermediate result scale for its internal division.  Comments?

One option would be to define a separate division operator that always
returns an integral value and that is truncated toward 0 and use that
for the mod function. People might find this operator useful in itself.

Another option would be for mod to check if the remainder doesn't have the
same sign as the divisor and if so keeping adding the divisor to it until
it does.

In response to

pgsql-general by date

Next:From: Mark KirkwoodDate: 2004-04-28 08:10:53
Subject: Re: TPC H data
Previous:From: Tom LaneDate: 2004-04-28 06:01:00
Subject: Re: Arbitrary precision modulo operation

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group