Search Postgresql Archives

Re: Arbitrary precision modulo operation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to majordomo@postgresql.org so that your
      message can get through to the mailing list cleanly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux