LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-24-2006, 12:20 AM   #16
ppanyam
Member
 
Registered: Oct 2004
Location: India
Distribution: Redhat
Posts: 88

Rep: Reputation: 15

Dear chief_officer,

The moment I saw your code involving comaring doubles, I knew where it will lead to.

I am also from an era of main frame with an array processor which was slower than a 486 running dos. And dozens of guys used to work on it! First thing they taught us there was not to waste time comparing floats without first rounding off.

Like jinkels said, it is all about how well math libraries are implemented in a language. Some languages are better than others. Even in Fortran, there are differences in different compilers. And IBM has developed a more accurate library etc.

The following link is a must for anyone doing scientific computing.

http://en.wikipedia.org/wiki/Floating_point

I like thia part particularly:

Quote:
Floating point arithmetic is not associative. This means that in general for floating point numbers x, y, and z:



Floating point arithmetic is also not distributive. This means that in general:


In short, the order in which operations are carried out can change the output of a floating point calculation. This is important in numerical analysis since two mathematically equivalent formulas may not produce the same numerical output, and one may be substantially more accurate than the other.

For example, with most floating-point implementations, (1e100 - 1e100) + 1.0 will give the result 1.0, whereas (1e100 + 1.0) - 1e100 gives 0.0.
Finally, java has third party stuff for advanced math libraries. There are lot of articles at javaworld for java for scientists and engineers.

ppanyam
 
Old 05-24-2006, 12:25 AM   #17
ppanyam
Member
 
Registered: Oct 2004
Location: India
Distribution: Redhat
Posts: 88

Rep: Reputation: 15
Sorry that 2 formulae did not show up.
Floating point arithmatic is not associative:
(x+y) +z != x +(y+z)

Floating point arithmatic is not distributive:

x*(y+z) != (x*y) + (x*z);

ppanyam
 
Old 05-28-2006, 02:07 AM   #18
chief_officer
Member
 
Registered: Mar 2006
Location: Istanbul, TR
Distribution: Red Hat, CentOS, Ubuntu
Posts: 181

Original Poster
Rep: Reputation: 30
Dear All,

Thank you very much for all your informative posts. paulsm4's articles were great, and ppanyam's last post involving the distributive and associative properties of the floating values were awesome.

ppanyam, graemef, paulsm4, jlinkels, Centinul... Thank you very much once again.

Regards.

Mental note [@jlinkels] I will review my high school mathematics regarding Taylor Series [goto 13 years back ]
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mondrian OLAP+JAVA: whats wrong with my command line? zakidad Programming 4 06-14-2005 03:40 AM
FC3 installed Limewire crashes with wrong Java version arst05 Fedora 10 03-21-2005 12:32 PM
my time is wrong and calender is also wrong Paxmaster Linux - General 6 12-16-2004 12:46 AM
Can anyone help me to identify what is wrong with this Java code? babyboss Programming 2 10-03-2004 11:28 AM
Shell says wrong Java version.. pipelok-j Linux - Software 2 06-16-2004 06:32 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration