Re: Arbitrary precision modulo operation - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: Arbitrary precision modulo operation
Date
Msg-id 20040426174226.GE18684@wolff.to
Whole thread Raw
In response to Arbitrary precision modulo operation  (Chadwick Boggs <chadwickboggs@yahoo.com>)
List pgsql-general
On Mon, Apr 26, 2004 at 13:30:17 -0400,
  Chadwick Boggs <chadwickboggs@yahoo.com> wrote:
> 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?

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: shadowing (like IB/Firebird)
Next
From: David Garamond
Date:
Subject: Re: shadowing (like IB/Firebird)