This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Problem with double precision in g77


Hi,

I am using RedHat 9.0 with gcc 3.2 on AMD. I wrote a
very simple program which is given below:

**************
      implicit double precision(a-z)
      open(7,file='test.dat',status='old')
                                                      
                                                      
               
      do 10 i = 1, 21
         read(7,*)a
                                                      
                                                      
                       n = 0.2d0
         p = (0.1d0 + n)
                                                      
                                                      
               
         if(a .eq. p)then
           print*,a
         endif
10    continue
       close(7)
       end
*****************
The data file test.dat contains
*****************
  0.
  0.1
  0.2
  0.3
  0.4
  0.5
  0.6
  0.7
  0.8
  0.9
  1.
  1.1
  1.2
  1.3
  1.4
  1.5
  1.6
  1.7
  1.8
  1.9
  2.
********************

The program simply reads the data file and writes if
the "if" condition is satisfied. There is no problem
in compilation with g77 and f77. 

When I change the value of "n" from 0 to 0.1, it
prints correct values. But when I put n = 0.2, it does
not print any output. 
Similarly it does not print output for n = 0.7 while
it prints for other values.

It prints correctly for all values of "n" if I remove
the "if" condition.

It prints correctly all values if I remove double
precision even with "if" condition.

I checked this program on RedHat 9.0 gcc 3.2 on
Pentium IV, SUSI on Pentium IV also. Same things
happened.

Could you please tell what the problem is.

Thank you very much.

Manoj Gupta
 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]