home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / hp / 9360 < prev    next >
Encoding:
Internet Message Format  |  1992-08-17  |  1.4 KB

  1. Path: sparky!uunet!dtix!darwin.sura.net!mips!swrinde!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!ceg.uiuc.edu!lee
  2. From: lee@ceg.uiuc.edu (Chris Lee)
  3. Newsgroups: comp.sys.hp
  4. Subject: comparisons in fortran:single or double?
  5. Keywords: strange results in comparisons
  6. Message-ID: <lee.714082981@ceg.uiuc.edu>
  7. Date: 17 Aug 92 20:23:01 GMT
  8. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  9. Organization: University of Illinois at Urbana
  10. Lines: 37
  11.  
  12.  
  13. Could some compiler guru help me on this?
  14.  
  15. We are running 8.07 on 700s, and I have been getting some strange
  16. behavior from the compiler.
  17.  
  18. I have 2 variables A and B, and I compare A and B.  The fortran line
  19. goes like
  20.  
  21.       if (a.ge.b) then
  22.          do this thing
  23.       else
  24.       ...
  25.  
  26. The values of A and B are both 4.4E-07, but the IF fails!  So I assign
  27. the value of A to a double precision variable just for curiosity and get 
  28. the following.
  29.  
  30.               A                     B
  31. real          4.40000E-07           4.40000E-07 
  32. double prec   4.399999795623444E-07 [unprinted]
  33.  
  34. Does the compiler actually do the comparisons in double precision or 
  35. something like that?  My conventional wisdom tells me that since both
  36. A and B are declared as real, the comparison should be done as reals, and
  37. the IF should evaluate as true but...
  38.  
  39. The code is about 5000 lines, so I don't think HP RC wants to look at
  40. it in its entirety.
  41.  
  42.  
  43. Thanks in advance
  44. -- 
  45. Chris Lee
  46. University of Illinois Urbana
  47. lee@ceg.uiuc.edu
  48. (217)244-2903
  49.