hi,
I'm comparing double and expnential numbers.
I have a file which contains id and corresponding double or
exponential no.
I have to get highest no. and its corresponding id.
I'm using arraylists, aray for storing values.
I'm not able to compare nos. with exponential part e.g: 3.01706E-12,
etc.
what should do???
Christian - 12 Jun 2007 11:17 GMT
ruds schrieb:
> hi,
> I'm comparing double and expnential numbers.
[quoted text clipped - 5 lines]
> etc.
> what should do???
could you be a bit more specific why
Double.compare(d1,d2); doesn't work?
like:
Comparator<IDDouble> comp = new Comparator<IDDouble>() {
public int compare(IDDouble a, IDDouble b) {
return Double.compare(a.no , b.no);
}
};
IDDouble max = Collections.max(arraylist, comp);
double is a number with an exponent. where is the difference? how about
transforming them to double for the comparisson ?
ruds - 12 Jun 2007 11:33 GMT
That wht i'm doing.
coverting string to double and them comparing
if(max1 > val1)
{
...
}
Lew - 12 Jun 2007 15:44 GMT
> That wht i'm doing.
> coverting string [sic] to double and them comparing
> if(max1 > val1)
> {
> ...
> }
The presence of an "exponential part" should have absolutely no effect on your
conversion. How exactly are you converting the numbers from String?
Provide an SSCCE - a simple, self-contained correct (compilable) example. All
the hand-waving and paraphrasing isn't helping.

Signature
Lew