将BigInteger存储到Mysql中 [英] Store BigInteger into Mysql

查看:1364
本文介绍了将BigInteger存储到Mysql中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于数学约束,我必须使用BigInteger类来表示值。



经过一些计算后,我想存储结果(由2x BigInteger实例)into Mysql ...



存储此类对象的最佳数据类型是什么?



使用Blob来存储这些结果的二进制格式(128位)?但我想避免不必要的类型转换。

解决方案

我建议使用Blob,然后 BigInteger(byte [] val)构造函数从字节数组转到BigInteger,而使用 BigInteger#toByteArray() / p>

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.

解决方案

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.

这篇关于将BigInteger存储到Mysql中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆