Reputation: 3
Is there a way to check greater values then "2147483648"? I have to work with numbers up to "6.73297395398192e212" (2^707). The data is stored in a mysql-database as float.
Maybe I'm just using the wrong search terms or there is not a good way.
Upvotes: 0
Views: 1166
Reputation: 11106
A double precision value uses 8 bytes, and you obviously cannot store 707 bits in those (which I assume you are trying to do). It can store a value of 1e308 by an approximation that costs precision in the lower digits, which makes it a bad choice for storing data that you want to do bitwise operations on. For bitwise operation on 8 bytes, you can use bigint.
Since MySQL 8, MySQL supports bitwise operations on binary string of arbitrary length, so you should store your value that way - a bit array is basically a binary string anyway. You cannot treat them as numbers though (e.g. add or multiply them like integers).
For earlier MySQL versions, bit operations on binary strings were limited to 8 bytes. You should still store your bits as a binary string (which allows for an easy upgrade), and write a small function that does the operation e.g. bytewise.
Upvotes: 1