Re: Divisibility of a java.math.BigInteger object
- From: rossum <rossum48@xxxxxxxxxxxx>
- Date: Wed, 09 Jul 2008 16:39:14 +0100
On 9 Jul 2008 14:15:50 GMT, ram@xxxxxxxxxxxxxxxxxx (Stefan Ram) wrote:
Calculating the remainder of a java.math.BigInteger objectHow fast is BigInteger.mod() compared with BigInteger.remainder()?
seems to be slow. For a number > 100, it would be sufficient
and possibly faster to just extract the two least significant
digits and compare them with »00«. But I can not directly
access the internal representation of a java.math.BigInteger
object. Does anyone see a possibility to accelerate such a
divisibility test for a java.math.BigInteger object using the
same tricks one uses when testing this by mental arithmetic?
What about BigInteger.divideAndRemainder()?
To access the internal representation of a BigInteger use
BigInteger.toByteArray() or for the least significant bits use
BigInteger.longValue() and similar. Use toString() for the
represenataion in decimal digits, though I suspect that will be too
slow for your purposes.
rossum
.
- Prev by Date: Accessing value of a session bean on a JSF page
- Next by Date: Re: Three New JDK versions
- Previous by thread: Accessing value of a session bean on a JSF page
- Next by thread: Re: Divisibility of a java.math.BigInteger object
- Index(es):
Relevant Pages
|