Yet again, The Sky is Falling! [message #52872] |
Thu, 08 March 2007 10:12  |
yp
Messages: 42 Registered: February 2005
|
Member |
|
|
This is yet another floating point mystery, and I am unable to figure
out which is the right way to deal:
I wrote this program ("Operation") in which I made sure that all
calculations are done in double precision. The program accepts 6
mandatory arguments and returns the output to "result".
Syntax: Operation, A, B, C, D, E, F, result
I get variable results (after 3rd decimal point) when I pass some of
the arguments as numbers and when I pass the same arguments as pre-
defined variables.
Case#1:
IDL> Operation, A, B, 0.0D, 0.0D, 0.0D, F, result
IDL> help, result
RESULT DOUBLE = Array[7]
IDL> print, result
1.0247013 1.0279051 1.0365066 1.0447064
1.0477210 1.0543893 1.0569390
Case#2:
IDL> C = (D = (E = 0.0D))
IDL> Operation, A, B, C, D, E, F, result
IDL> help, result
RESULT DOUBLE = Array[7]
IDL> print, result
1.0250284 1.0281385 1.0367149 1.0450368
1.0480349 1.0547703 1.0573193
Why is such discrepancy? In my problem the accuracy after 3rd decimal
point is not so important, however, after seeing the results I lose
confidence on IDL's capability on Real number arithmetic!
May be I am missing something?
Thanks,
yas
|
|
|