TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Classic View

Use Proportional Font
Show Text Part by Default
Show All Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
"Pickett, Michael" <[log in to unmask]>
Thu, 13 Feb 1997 10:18:00 +0000
TEXT/PLAIN (21 lines)
Hello Ray,

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.

--Michael Pickett--
(responding personally, and not on behalf of BAeSEMA)

ATOM RSS1 RSS2