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

From Harald Fuchs
Subject Re: Arbitrary precision modulo operation
Date
Msg-id puhdv5eexe.fsf@srv.protecting.net
Whole thread Raw
In response to Arbitrary precision modulo operation  (Chadwick Boggs <chadwickboggs@yahoo.com>)
List pgsql-general
In article <408D4729.303@yahoo.com>,
Chadwick Boggs <chadwickboggs@yahoo.com> writes:

> 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)

Is the name of the other, unnamed RDBMS by chance starting with an
'M'?  ;-)

Anyway, both are wrong.  According to GNU MP, the correct answer is
117.  Thus PostgreSQL is at least almost right (117 - 123 = -6).

pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: questions on rules
Next
From: Robert Treat
Date:
Subject: Re: shadowing (like IB/Firebird)