Is Fortran more accurate than Java ?

From: mmquan (xiejingquan_at_126.com)
Date: 06/29/04


Date: 29 Jun 2004 09:02:21 -0700

public class ex4{
        public static void main(String[] args){
                double eps[] = new double[5];
                double a12, a34;
                eps[1] = Double.longBitsToDouble(0x4037CB020C49BA5EL);
                eps[2] = Double.longBitsToDouble(0x403C1E76C8B43958L);
                eps[3] = Double.longBitsToDouble(0xBFF943D46B26BF87L);
                eps[4] = Double.longBitsToDouble(0xBFF943D46B26BF87L);
                System.out.println(Long.toHexString(Double.doubleToLongBits(eps[1]*eps[2]-eps[3]*eps[4])));
                a12 = eps[1]*eps[2];
                a34 = eps[3]*eps[4];
                System.out.println(Long.toHexString(Double.doubleToLongBits(a12-a34)));
        }
}
I wrote a similar program in Fortran, but I get different results of
the first output. I know the second output should be the same because
the two operands of the subtraction are rounded to 64 bits. But the
first one in Fortran is an intermediate results with 80 bits but what
about Java, did Java also use the same 80 bits as the subtraction
operands?
this is the output of Java:
4084d455e2cff391
4084d455e2cff391
this is the output of Fortran:
4084D455E2CFF392
4084D455E2CFF391
Thanks for your responding!



Relevant Pages

  • Re: Is Fortran more accurate than Java ?
    ... > the first output. ... > first one in Fortran is an intermediate results with 80 bits but what ... > about Java, did Java also use the same 80 bits as the subtraction ... it's not allowed to use the 80 bit registers for additional precision. ...
    (comp.lang.java.programmer)
  • Re: Comments from those devleoping niche software.
    ... I've written Fortran 95 programs ... > but very user-friendly analysis packages. ... > best of my knowledge as a bridge engineer) don't exist in any other ... Java would provide the business logic and front end. ...
    (comp.programming)
  • Re: Is Fortran more accurate than Java ?
    ... Fortran is far more portable ... >> than Java since it doesn't specify a detailed arithmetic model. ... Portability has a variety of shadings. ... There are still plenty of machines for which it is a problem but they ...
    (comp.lang.java.programmer)
  • Re: seeking advice for "translate" Fortran code to Java code
    ... redefine a common block as needed for each subroutine. ... Still, Java has no pointers, so I ... Java arrays are always what C would call arrays of pointers ... Fortran intrinsics in Java appropriately. ...
    (comp.lang.fortran)
  • Re: PL/I, COBOL, Advantages, Equivalence, et al
    ... But why Fortran and not Ada or Java? ... Java is simply not sufficiently powerful for number-crunching. ... The language requires so much ...
    (comp.lang.pl1)