Reputation: 163
I need to store very large numbers with hundreds or thousands of digits (like 999^999) in a database. How can I do this in MySQL? What data type should I use?
Also, I will need to subtract,compare, add the numbers. Is it possible to do so in a small time with MySQL?
Upvotes: 0
Views: 1273
Reputation: 1088
I know this isn't a great answer but the Postgres has bindings to GNU MP, the multi-precision library. If you aren't too far into your project you might consider switching databases. The MySQL docs make it clear that integer support tops out at [BIGINT], which is an 8-byte storage with about 18 places of accuracy.
the site for it is here: http://pgmp.projects.pgfoundry.org/mpz.html
I can't find any sign that anyone used the external bindings in MySQL to do something similar. To do this in MySQL you would either have to implement external bindings to a library like GMPLIB or store the data in MySQL as a [STRING] or as one of the [BLOB],[MEDIUMBLOB] types and then implement all your sorts and operations in code. That is a huge task.
Upvotes: 1