Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

Re: Divisibility of a java.math.BigInteger object

 
 
John B. Matthews
Guest
Posts: n/a
 
      07-09-2008
In article <(E-Mail Removed)-berlin.de>,
http://www.velocityreviews.com/forums/(E-Mail Removed)-berlin.de (Stefan Ram) wrote:

> | Supersedes: <(E-Mail Removed)-berlin.de>
>
> Calculating the remainder of a java.math.BigInteger object
> | seems to be slow. To test divisibility by 100, for a number
> | larger than 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?


If BigIntegers are stored in two's-complement form (they are only
required to behave that way) then getLowestSetBit() might be a faster
test for divisibility by powers of two.

Using toString(int radix), you can examine any glyph in a BigInteger's
representation in any base up to Character.MAX_RADIX. The conversion
will likely be slower than a remainder, but you only have to do it once
to check a number of divisibility shortcuts for small integers. Sadly,
the conversion itself is usually done with a series of divisions, so I
don't see a net gain.

Sorry, I lost track of the larger goal.

> (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:
> [...]
> 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.)


Some Java profilers (NetBeans, Eclispe, others?) let you focus on
subsets of the code for a clearer picture.

--
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews
 
Reply With Quote
 
 
 
 
Stefan Ram
Guest
Posts: n/a
 
      07-09-2008
"John B. Matthews" <(E-Mail Removed)> writes:
>Some Java profilers (NetBeans, Eclispe, others?) let you focus on
>subsets of the code for a clearer picture.


The »Performance Analysis« program by Sun Microsystems, Inc.
has a panel named »by Caller«. Often a subset of the code can
by identified by its callers. So one also can use this
»standard tool« (where »standard« means »by Sun Microsystems,
Inc.«) for some queries.

http://java.sun.com/developer/techni.../perf%61n%61l/

 
Reply With Quote
 
 
 
 
John B. Matthews
Guest
Posts: n/a
 
      07-09-2008
In article <(E-Mail Removed)-berlin.de>,
(E-Mail Removed)-berlin.de (Stefan Ram) wrote:

> "John B. Matthews" <(E-Mail Removed)> writes:
> >Some Java profilers (NetBeans, Eclispe, others?) let you focus on
> >subsets of the code for a clearer picture.

>
> The »Performance Analysis« program by Sun Microsystems, Inc.
> has a panel named »by Caller«. Often a subset of the code can
> by identified by its callers. So one also can use this
> »standard tool« (where »standard« means »by Sun Microsystems,
> Inc.«) for some queries.
>
> http://java.sun.com/developer/techni.../perf%61n%61l/


Thank you for the informative link. I see that Sun's NetBeans' profiler
uses the hprof format, bit I was surprised that some of the Eclipse
plugins do not mention it explicitly.

--
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews
 
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 Patricia Shanahan Java 2 07-09-2008 04:14 PM
Divisibility of a java.math.BigInteger object Stefan Ram Java 0 07-09-2008 02:15 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