BigInteger.valueOf()用于很大的数字吗? [英] BigInteger.valueOf() for very big numbers?

查看:525
本文介绍了BigInteger.valueOf()用于很大的数字吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java中将50位字符串转换为BigInteger的最佳方法是什么?它没有valueOf(String)方法,而且由于它太小,我无法转换为Long.

What would be the best way to convert a 50-digit String to a BigInteger in Java? It doesn't have a valueOf(String) method, and I can't convert to Long because it's too small.

推荐答案

它确实具有

It does have a BigInteger(String) constructor :-)

String S = "12345678901234567890123456789012345678901234567890";
BigInteger bi = new BigInteger(S);

这篇关于BigInteger.valueOf()用于很大的数字吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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