从Integer转换为BigInteger [英] Converting from Integer, to BigInteger

查看:619
本文介绍了从Integer转换为BigInteger的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有任何方法可以将Integer类型的变量转换为BigInteger。我尝试了对Integer变量进行类型转换,但是我得到一个错误,表示不可转换的类型。

I was wondering if there was any way to convert a variable of type Integer, to BigInteger. I tried typecasting the Integer variable, but i get an error that says inconvertible type.

推荐答案

你想要的方法是 BigInteger #valvalOf(long val)

例如,

BigInteger bi = BigInteger.valueOf(myInteger.intValue());

首先创建字符串是不必要的,也是不受欢迎的。

Making a String first is unnecessary and undesired.

这篇关于从Integer转换为BigInteger的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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