Re: Arbitrary precision modulo operation
| От | Harald Fuchs |
|---|---|
| Тема | Re: Arbitrary precision modulo operation |
| Дата | |
| Msg-id | puhdv5eexe.fsf@srv.protecting.net обсуждение исходный текст |
| Ответ на | Arbitrary precision modulo operation (Chadwick Boggs <chadwickboggs@yahoo.com>) |
| Список | 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 по дате отправления: