I have a BigInteger I want to divide by two. I tried this:
我有一个BigInteger我想要除以2。我试过这个:
suma=suma.divide(2);
or
BigInteger a=2;
or
suma=suma.divide(BigInteger(2));
Still the same error saying that 2 is an int. I am so sorry for such noobish questions.
仍然是同样的错误,说2是一个int。我很抱歉这些无聊的问题。
5 个解决方案
#1
2
Try using the following to create a BigInteger with the value 2:
尝试使用以下命令创建值为2的BigInteger:
BigInteger bigTwo = BigInteger.valueof(2L);
#2
1
BigInteger Big = new BigInteger("2");
its the best way,since if you just assign the numeric 2 or other whole number it will default to integer,as with floats.
它是最好的方法,因为如果你只是分配数字2或其他整数,它将默认为整数,就像浮点数一样。
#3
0
Try:
BigInteger bigInt = new BigInteger("2");
To divide:
BigInteger bigInt = new BigInteger("2");
BigInteger bigInt2 = new BigInteger("4");
bigInt2 = bigInt2.divide(bigInt);
#4
0
You cannot divind a BigInteger value with an integer. You should do it as follows:
您不能将BigInteger值与整数分开。你应该这样做:
BigInteger div = BigInteger.valueOf(2);
BigInteger var = BigInteger.valueOf(100);
var = var.divide(div);
It will do your job..
它会完成你的工作..
#5
-1
Try this:
suma=suma.divide(BigInteger.valueOf(2));
#1
2
Try using the following to create a BigInteger with the value 2:
尝试使用以下命令创建值为2的BigInteger:
BigInteger bigTwo = BigInteger.valueof(2L);
#2
1
BigInteger Big = new BigInteger("2");
its the best way,since if you just assign the numeric 2 or other whole number it will default to integer,as with floats.
它是最好的方法,因为如果你只是分配数字2或其他整数,它将默认为整数,就像浮点数一样。
#3
0
Try:
BigInteger bigInt = new BigInteger("2");
To divide:
BigInteger bigInt = new BigInteger("2");
BigInteger bigInt2 = new BigInteger("4");
bigInt2 = bigInt2.divide(bigInt);
#4
0
You cannot divind a BigInteger value with an integer. You should do it as follows:
您不能将BigInteger值与整数分开。你应该这样做:
BigInteger div = BigInteger.valueOf(2);
BigInteger var = BigInteger.valueOf(100);
var = var.divide(div);
It will do your job..
它会完成你的工作..
#5
-1
Try this:
suma=suma.divide(BigInteger.valueOf(2));