# Thread: Problem getting biginteger to work

1. Member Join Date
Jan 2013
Posts
7
Rep Power
0

## Problem getting biginteger to work

I want to do this with bigintegers
Java Code:
` if(MaxNum%x == 0)`
note that MaxNum is a big integer and x is just a regular integer.
I tried writing
Java Code:
`if(MaxNum.mod(x) == 0)`
but the compiler tells me to convert x to a big integer which I rather avoid if possible.  Reply With Quote

2. Senior Member Join Date
Jun 2007
Location
Bali, Indonesia
Posts
762
Rep Power
14

## 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).  Reply With Quote

3. Member Join Date
Jan 2013
Posts
7
Rep Power
0

## Re: Problem getting biginteger to work Originally Posted by wsaryada 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?
Java Code:
`if(MaxNum.mod(BigInteger.valueOf(x)) == Zero)`
Where "Zero" is:
Java Code:
` BigInteger Zero= new BigInteger ("0");`
For some reason this just freezes my program. I get no error.  Reply With Quote

4. ## Re: Problem getting biginteger to work

Java Code:
`if(MaxNum.mod(BigInteger.valueOf(x)).equals(BigInteger.ZERO))`
kind regards,

Jos  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•