Search code examples
mysqlgmp

GMP functions for MySql


I have a php application that uses the bitwise functions from the GMP library - gmp_and, gmp_or, gmp_xor. I need to use gmp because my bit range exceeds the 64 bit integer limit.

I would like to hand this processing off to the mysql server however it seems that mysql doesn't have any equivalent functions. Are there any suitable extensions available? What other approaches could I use to process these arbitrary precision integers in mysql?

Thanks a million (1x10E6).


Solution

  • There is not a suitable extension to do GMP within MySQL. You could store your numbers as large strings, and use the PHP GMP wrapper to process them. Obviously, this isn't quite as efficient as a native datatype, but depending on your use case, it might be perfectly fine.

    If you're not tied to MySQL, Postgres does have an extension for GMP, which is pretty slick: http://pgmp.projects.postgresql.org/