Re: c vs java floating point errors under windows XP

From: ak (ak_at_workmail)
Date: 06/12/04


Date: Sat, 12 Jun 2004 08:07:55 +0800

On 11 Jun 2004 11:50:27 -0700, howe.charles@mayo.edu (valis) wrote:

>>I have an application that requires between 10^12 and 10^15 iterations
>>of a floating point calculation. The precision of the numbers must be
>>at least 20 digits for the math to work out. I have written an
>>algorithm in java and in C to accomplish this calculation. Under
>>Linux, both algorithms appear to work fine, and the accumulated error
>>does not impact on the outcome. However, in Windows, the java
>>algorithm seems to run fine but the C calculation (compiled with gcc
>>under MinGW) suffers from extreme error that renders the calculation
>>completely useless. Can anyone explain to me what the difference might
>>be between the java code (compiled under jdk1.3.1_03) and the C code
>>in terms of the floating point calculations? Also, what is the
>>difference between running the calculation on Linux vs WinXP? The
>>reason I cannot simply use the java algorithm is that the large number
>>of iterations takes several days in java, but only several hours in C.
>>
>>Thanx.

I believe the implementation of the floating point data type is OS dependent
e.g. little endian/big endian between HP Unix and Windows. In windows you
would get a max precision of 15-16 digits using double.

Java has a higher precision on their floats(IEEE 754) and is OS independent so
that is why they run (slow) on both machines.

/ak



Relevant Pages

  • Re: General Opinion on a how to?
    ... So different prize ... not have to change the database as you add new algorithm to the system. ... The way i see my calculation working with the aid of Jameys tips is this: ... Load into a prize pool object instance for that game ...
    (microsoft.public.dotnet.languages.csharp)
  • Feature suggestion: sum() ought to use a compensated summation algorithm
    ... I did the following calculation: Generated a list of a million random numbers between 0 and 1, constructed a new list by subtracting the mean value from each number, and then calculated the mean again. ... However, I noticed that the simple Python program below gives a result of ~ 10^-14, while an equivalent Mathematica program (also using double precision) gives a result of ~ 10^-17, i.e. three orders of magnitude more precise. ... A little research shows that Mathematica uses a "compensated summation" algorithm. ...
    (comp.lang.python)
  • Re: Kresss Probability Trilogy Qs
    ... We know our mathematics is true by direct insight, ... Any calculation has an experimental aspect to it (albeit one that is ... objections and answers which I'm ... Our "algorithm" is an ...
    (rec.arts.sf.science)
  • Salamin-Brent algorithm
    ... page of that title and learned of the Salamin-Brent algorithm (I'm new ... etc. (neglecting any benefits the binary calculation ... "floating point epsilon" problem, i.e., when the precision of the ...
    (sci.math)
  • Re: How to calculate pi in binary ?
    ... > calculating just the Nth digit of pi. ... "This algorithm is ... negligible) means that the constant term in the complexity analysis will ... This, in turn, will depend on the methods of calculation ...
    (sci.math)