home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / unix / ultrix / 8370 < prev    next >
Encoding:
Text File  |  1992-11-17  |  3.1 KB  |  93 lines

  1. Newsgroups: comp.unix.ultrix
  2. Path: sparky!uunet!gumby!wupost!cs.uiuc.edu!vela!amaranth
  3. From: amaranth@vela.acs.oakland.edu (Paul Amaranth)
  4. Subject: Re: FPU errors on 5000/240 P.Amaranth
  5. Message-ID: <1992Nov17.195628.15041@vela.acs.oakland.edu>
  6. Organization: Oakland University, Rochester MI.
  7. References: <1992Nov10.161523.20950@hubcap.clemson.edu> <1992Nov11.185218.15068@vela.acs.oakland.edu> <1eb0jpINNok9@nestroy.wu-wien.ac.at>
  8. Date: Tue, 17 Nov 1992 19:56:28 GMT
  9. Lines: 82
  10.  
  11. [much verbage deleted...]
  12.  
  13. In article <1eb0jpINNok9@nestroy.wu-wien.ac.at> hauser@wu-wien.ac.at writes:
  14. >An impressive exercise you will never forget is:
  15. >
  16. >    program noforget
  17. >    double precision a
  18. >    a=1.0d0
  19. >    call printa(a)
  20. >    stop
  21. >    end
  22. >    program noforget
  23. >    double precision a
  24. >    a=1.0d0
  25. >    call printa(a)
  26. >    stop
  27. >    end
  28. >c
  29. >    subroutine printa(a)
  30. >    double precision a
  31. >    print *, a
  32. >    end
  33. >ccc
  34. >now change the main program to
  35. >
  36. >    program noforget
  37. >    call printa(1.0)
  38. >    stop
  39. >    end  
  40. >c
  41. >If you use 1.0d0 everything is o.k., but not with 1.0 !          
  42. >
  43. >-- 
  44. >Michael Hauser
  45.  
  46. Not to flame on this, but you should at least know Fortran before
  47. critisizing.  Of course you will get different answers on printa when
  48. you call it with different data type arguments.  Fortran arguments
  49. are sent by reference, so the subroutine thinks it has a double
  50. precision argument, even when a single precision is sent.  God knows
  51. what's in the second word.  For that matter, you could send a character
  52. argument to printa and it would merrily interpret it as a double precision
  53. number.
  54.  
  55. Mixed mode arithmetic is defined in Fortran, so the integers in my
  56. little program example  will be converted to a double precision value
  57. for the calculations by the compiler.  Now most people would argue that
  58. it's good form to use double precision constants and explicitly convert
  59. integers to double precision using a dfloat function, and I wouldn't argue,
  60. but it's not necessary.  Here's a quote from a DEC fortran manual:
  61.  
  62.    ... Any integer elements [in a real calculation] are converted to the real
  63.    data type ...
  64.  
  65. and
  66.  
  67.    ... Any element in an operation in which there is a higher-precision
  68.    element is converted to the data type of the higher-precision element
  69.    by making the existing element the most significant portion of the 
  70.    higher-precision data.  The least significant protion of the binary
  71.    representation is zero.
  72.  
  73.  
  74. Sheesh.
  75.  
  76. BTW: these same types of calculations are the reason the Smith FPU
  77.      test program fails.  I just got rid of the noise.
  78.  
  79. And if you read the original post, you would have seen that it works
  80. fine and consistently on either non 5000/240 hardware or fixed 5000/240
  81. hardware.  You only get wierd results on a non-fixed 5000/240 (some
  82. processors only). This is using the SAME object, only different
  83. platforms (so it's not a compiler problem).
  84.  
  85. Double sheesh.
  86.  
  87. I don't have time for this.
  88. -- 
  89. Paul Amaranth  Manager User Services - office: (313) 370 4541 (also voicemail)
  90. (internet)     amaranth@vela.acs.oakland.edu  |    This space 
  91. (bitnet)       amaranth@oakland               |    temporarily
  92. (uucp)         ...!uunet!umich!vela!amaranth  |      empty
  93.