Trouble in comparing exponential numbers.

R

ruds

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???
 
C

Christian

ruds said:
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???
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 ?
 
R

ruds

That wht i'm doing.
coverting string to double and them comparing
if(max1 > val1)
{
...
}
 
L

Lew

ruds said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top