Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Divisibility of a java.math.BigInteger object

Reply
Thread Tools

Divisibility of a java.math.BigInteger object

 
 
Stefan Ram
Guest
Posts: n/a
 
      07-09-2008
Calculating the remainder of a java.math.BigInteger object
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?

(This is not premature optimization. I already have a program
that is too slow, and a profiler showed that it spends a
significant amount of time in java.math.BigInteger.remainder:

java.math.BigInteger.remainder 1.35 %
java.math.BigInteger.<init> 1.01 %
java.math.BigInteger.add 1.01 %
java.math.BigInteger.divide 0.68 %
java.math.BigInteger.valueOf 0.68 %
java.math.BigInteger.subtract 0.34 %
java.math.BigInteger.multiply 0.34 %

Because the profiler also includes program startup and other
phases of the process, the percentage of the
java.math.BigInteger.remainder operation is larger then shown
above when put in relation to the actual calculation phase.)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Divisibility of a java.math.BigInteger object John B. Matthews Java 2 07-09-2008 08:34 PM
Re: Divisibility of a java.math.BigInteger object Patricia Shanahan Java 2 07-09-2008 04:14 PM
Object creation - Do we really need to create a parent for a derieved object - can't the base object just point to an already created base object jon wayne C++ 9 09-22-2005 02:06 AM
Error:Object reference not set to an instance of an object. Suresh Kojhani ASP .Net 1 07-29-2004 12:10 PM
Error !Object reference not set to an instance of an object. !!! Help Parthiv Joshi ASP .Net 2 07-02-2004 10:28 AM



Advertisments