Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2007

Tip: Looking for answers? Try searching our database.

Trouble in comparing exponential numbers.

Thread view: 
ruds - 12 Jun 2007 10:48 GMT
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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.