delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1993/04/26/12:27:37

Date: Mon, 26 Apr 1993 13:33:29 GMT
From: FINE AT main2 DOT jinr DOT dubna DOT su (Dr.Valery Fine LCTA/JINR Dubna)
Subject: Bug in float operation
To: djgpp AT sun DOT soe DOT clarkson DOT edu

  Hi Netters,

  I have tried the short fortran code pointed below:


        program ttt
        XMIP= .5895782470703125E+03

        TXMIP =XMIP
        TXMIP2=XMIP*XMIP

        TXM=TXMIP*TXMIP

        TXMERR=TXMIP2 - TXMIP*TXMIP
        TXMER2=txmip2 - txm

        WRITE (*,1100) 'TXMIP2 TXM*TXM=',TXMIP2,TXM
        WRITE (*,1100) 'TXMER2 TXMERR =',TXMER2,TXMERR
 1100   FORMAT(/A16,E32.25,/16X,E32.25)
        END


  with 
       ==>    f2c ttt.f

    and have got the following C text, than do a.out with

       ==>    gcc ttt.c -lf2c -lm -lc

    Obviously that the second WRITE must print two zerous, but what
I have really got see at the end of this message. 
   It is clear that multiply and subtract operations have been done by
co-processor with a higher accuracy that one needs, but I cannot figure out
how to work around this situation along big code I am trying to port
(I mean CERN GEANT simulation code - about 200 thousand fortran statements).

   Any your suggestion.

   Regards
   Valery

=================================================================
Dr. Valery Fine /LCTA            Telex 911621 dubna su
                                 Fax (+7 095) 975 23 81
Joint Inst. for Nuclear Res.     Email: fine AT main1 DOT jinr DOT dubna DOT su
Head Post Office, PO Box 79             fine AT vxcern DOT cern DOT ch
Moscow, 101000
Russia
======================================================================

/* tsqrt.f -- translated by f2c (version of 12 March 1993  7:07:21).
   You must link the resulting object file with the libraries:
	-lf2c -lm   (in that order)
*/

#include "f2c.h"

/* Table of constant values */

static integer c__1 = 1;

/* Main program */ MAIN__()
{
    /* Format strings */
    static char fmt_1100[] = "(/a16,e32.25,/16x,e32.25)";

    /* Builtin functions */
    integer s_wsfe(), do_fio(), e_wsfe();

    /* Local variables */
    static real xmip, txmip, txmer2, txmip2, txmerr, txm;

    /* Fortran I/O blocks */
    static cilist io___7 = { 0, 6, 0, fmt_1100, 0 };
    static cilist io___8 = { 0, 6, 0, fmt_1100, 0 };


    xmip = (float)589.5782470703125;
    txmip = xmip;
    txmip2 = xmip * xmip;
    txm = txmip * txmip;
    txmerr = txmip2 - txmip * txmip;
    txmer2 = txmip2 - txm;
    s_wsfe(&io___7);
    do_fio(&c__1, "TXMIP2 TXM*TXM=", 15L);
    do_fio(&c__1, (char *)&txmip2, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&txm, (ftnlen)sizeof(real));
    e_wsfe();
    s_wsfe(&io___8);
    do_fio(&c__1, "TXMER2 TXMERR =", 15L);
    do_fio(&c__1, (char *)&txmer2, (ftnlen)sizeof(real));
    do_fio(&c__1, (char *)&txmerr, (ftnlen)sizeof(real));
    e_wsfe();
/*        return */
} /* MAIN__ */

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


 TXMIP2 TXM*TXM=  .3476025000000000000000000E+06
                  .3476025000000000000000000E+06

 TXMER2 TXMERR =  .0000000000000000000000000E+00
                 -.9418502449989318847656250E-02


- Raw text -


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