Search Postgresql Archives

Re: Arbitrary precision modulo operation

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

 



On Mon, Apr 26, 2004 at 10:18:52 -0400,
  Chadwick Boggs <chadwickboggs@yahoo.com> wrote:
> I need to perform modulo operations on extremely large numbers.  The % 
> operator is giving me number out of range errors and the mod(x, y) 
> function simply seems to return the wrong results.  Also, my numerator 
> is in the format of a quoted string, which the mod function can't take.

How large is extremely large?
You can cast the strings to a numeric type to solve the string problem.
'numeric' should work for numbers up to about 1000 digits.
For example:
area=> select '1234567890'::numeric % '123'::numeric;
 ?column?
----------
       39
(1 row)

If you are getting wrong results you should post a specific example so
that the developers can figure out what is going wrong.

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