# Problem getting biginteger to work

• 01-18-2013, 12:08 AM
Sulfuri
Problem getting biginteger to work
I want to do this with bigintegers
Code:

` if(MaxNum%x == 0)`
note that MaxNum is a big integer and x is just a regular integer.
I tried writing
Code:

`if(MaxNum.mod(x) == 0)`
but the compiler tells me to convert x to a big integer which I rather avoid if possible.
• 01-18-2013, 06:41 AM
Re: Problem getting biginteger to work
All calculation methods in BigInteger class require you to use BigInteger as the parameter. These methods like add(), mod(), multiply(), divide(), etc. There's no overload that I can see that accept integer. So you have to convert it. You can do by using BigInteger.valueOf(x).
• 01-18-2013, 05:48 PM
Sulfuri
Re: Problem getting biginteger to work
Quote:

All calculation methods in BigInteger class require you to use BigInteger as the parameter. These methods like add(), mod(), multiply(), divide(), etc. There's no overload that I can see that accept integer. So you have to convert it. You can do by using BigInteger.valueOf(x).

Do you mean for it to be like this?
Code:

`if(MaxNum.mod(BigInteger.valueOf(x)) == Zero)`
Where "Zero" is:
Code:

` BigInteger Zero= new BigInteger ("0");`
For some reason this just freezes my program. I get no error.
• 01-18-2013, 06:27 PM
JosAH
Re: Problem getting biginteger to work
`if(MaxNum.mod(BigInteger.valueOf(x)).equals(BigInteger.ZERO))`