Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Store BigInteger into Mysql

Due to mathematica constraints I've to use the BigInteger class to represent values.

After some calculations I would like to store the result (given by 2x BigInteger instances) into Mysql...

What is the best datatype to store such object ?

I was thinking about using a Blob to store the binary format of those results (128 bits) ? But I would like to avoid unnecessary type conversions.

like image 523
Kami Avatar asked Dec 13 '22 17:12

Kami


1 Answers

I would recommend using a Blob and then the BigInteger(byte[] val) constructor to go from byte array to BigInteger, and the BigInteger#toByteArray() method for the other way.

like image 111
aioobe Avatar answered Dec 24 '22 23:12

aioobe