delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1993/05/24/08:59:02

Date: 24 May 93 13:16:00 +0003 (GMT+3:00)
From: "Fine-62701 219828" <fine AT main1 DOT jinr DOT dubna DOT su>
Subject: Wrong cos() ???
To: "djgpp" <djgpp AT sun DOT soe DOT clarkson DOT edu>

      Hi 

       I have had a strange result trying to calculate cos() function
       with   f2c + gcc
       
       A result has been provided by IBM PC differs from it done by
       as IBM/VM as VAX/VMS on a power !!! 
       
       Does anybody know how could one work around this problem?

          Thanks in advance?

       Valery
===================== Cut here =======================
      PROGRAM TEST
      DOUBLE PRECISION PI,X,Z,Y,S
      PARAMETER (PI = 3.14159 26535 89793 24D0)
      DATA Z /-20.5/
        X=PI*Z
        Y=COS(X)
        write(*,*) 'COS(X)= ',Y
        STOP
        END
===================== Cut here =======================
               
 COS(X)=   7.83951354E-15   computed by IBM PC 486/25 MSDOS v.5.0 + DJGPP
           7.34169098E-16   computed by IBM/VM
           7.34169098E-16   computed by VAX/VMS

============== This is the C equivalent of above ===============
===================== Cut here =======================
/* test_t.f -- translated by f2c (version of 23 April 1993  18:34:30).
   You must link the resulting object file with the libraries:
	-lf2c -lm   (in that order)
*/

#include "f2c.h"

/* Main program */ MAIN__()
{
    /* Initialized data */

    static doublereal z = -20.5;

    /* Builtin functions */
    double cos();

    /* Local variables */
    static doublereal x, y;

    x = z * 3.14159265358979324;
    y = cos(x);
    printf(" cos(x) = %e",y);
} /* MAIN__ */

/* Main program alias */ int test_ () { MAIN__ (); }



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019