Thu, 13 Feb 1997 10:18:00 +0000
Floating point is tricky stuff. I don't think you should be surprised that
adding five floating point numbers together in different orders gives very
slightly different results. It might be wise to suspect that your printed
results are not telling you the full story. For example, it is possible that
the conversion from binary to decimal is giving the same decimal result for
different binary numbers, perhaps due to limitiations in the conversion
routine. I suggest you take a look at the binary representations of your path
lengths. You may find that it makes sense to put in a small tolerance on the
comparison, rather than test for exact equality.
I note that you had to tweak your Common Lisp program because of
discrepancies in the 15th digit. In your Ada program, you have specified your
floating point type as only 8 digits. I don't know what representation GNAT
uses for this type, but if you are only interested in 8 digits, you ought to
set the tolerance in your comparison to reflect this.
(responding personally, and not on behalf of BAeSEMA)