## Re: Arbitrary precision modulo operation

From: "Dann Corbit" "Bruno Wolff III" ,"Chadwick Boggs" Re: Arbitrary precision modulo operation 2004-04-26 19:48:45 D90A5A6C612A39408103E6ECDD77B829408D69@voyager.corporate.connx.com (view raw, whole thread or download thread mbox) 2004-04-26 19:48:45 from "Dann Corbit"  2004-04-27 01:55:56 from Alvaro Herrera   2004-04-28 03:18:22 from Paul Tillotson    2004-04-28 06:01:00 from Tom Lane     2004-04-28 07:04:43 from Bruno Wolff III pgsql-general
```Maple output:
y := 123456789012345678901234567890 mod 123;
y := 117

CONNX output (which uses qfloat by S. Moshier):
select mod(123456789012345678901234567890 , 123) {nopassthrough}
117

PariGP output:
? Mod(123456789012345678901234567890, 123)
%4 = Mod(117, 123)
?

> -----Original Message-----
> From: Bruno Wolff III [mailto:bruno(at)wolff(dot)to]
> Sent: Monday, April 26, 2004 10:42 AM
> Cc: pgsql-general(at)postgresql(dot)org
> Subject: Re: [GENERAL] Arbitrary precision modulo operation
>
>
> On Mon, Apr 26, 2004 at 13:30:17 -0400,
> > Example of wrong results from modulo operation of arbitrary
> precision
> > numbers:
> >
> > # select '123456789012345678901234567890'::numeric % 123; ?column?
> > ----------
> >       -6
> > (1 row)
> >
> > # select mod('123456789012345678901234567890'::numeric, 123); mod
> > -----
> >  -6
> > (1 row)
> >
> > The correct result (at least according to another, unnamed, RDBMS):
> >
> > > select '123456789012345678901234567890' % 123;
> > +----------------------------------------+
> > | '123456789012345678901234567890' % 123 |
> > +----------------------------------------+
> > |                                     58 |
> > +----------------------------------------+
> > 1 row in set (0.00 sec)
>
> I checked this with bc and I got -6 (and 117) as being
> correct. I would think the other database was wrong.
>
> It wouldn't happen to be MYSQL would it?
>
> ---------------------------(end of
> TIP 1: subscribe and unsubscribe commands go to
> majordomo(at)postgresql(dot)org
>

```

### pgsql-general by date

 Next: From: Guy Fraser Date: 2004-04-26 19:58:57 Subject: Re: 7.3.4 on Linux: UPDATE .. foo=foo+1 degrades massivly Previous: From: Alvaro Herrera Date: 2004-04-26 19:46:45 Subject: Re: 7.3.4 on Linux: UPDATE .. foo=foo+1 degrades massivly