Re: CDC Floating point = tests?
- From: nospam@xxxxxxxxxxxxx (Richard Maine)
- Date: Tue, 30 Jan 2007 20:54:04 -0800
stocksami@xxxxxxxxxxxxx <stocksami@xxxxxxxxxxxxx> wrote:
On the old CDC machines running EKS you could use a regular if test to
see if two floating point values were equal, and it worked! I've
ported lots of code from EKS to other platforms and I've had to change
those lines of codes many many times.
I'm not sure exactly what your question really is. First, it sounds as
though you are surprised that testing floating point values for equality
can ever work. Well, it can. No special compiler tricks are necessary.
It is a simple operation that any Fortran compiler can do - and can do
correctly. I half wonder whether you might be seeing warning messages
from other compilers and overreacting to them. There are compilers that
will give you a warning for every attempt to compare two floating point
numbers for equality. That is only a warning, suggesting that this might
be a bad idea. It does *NOT* mean that it won't work; it will work.
Whether it is a good idea is a separate matter. Sometimes it is a
perfectly fine idea. Other times it is not.
The other posters have concentrated on the question of why it is
sometimes not a good idea, what can be done about those cases, why the
results of the problematic cases can vary among compilers, and related
matters.
But your question seemed to me to have a hint of suprise that any code
could ever work with floating point equality tests. Perhaps I misread
that hint, but I thought it worth clarifying the sim ple case first. I
have seen people who had perfectly valid and "safe" code, but thought
that they had to change it because the compiler gave them a warning
message. The people did not understand the distinction between a warning
and an error. That might not be the case for you, in which case I
apologize for making a "trivial" point. But it seemed worth making just
in case.
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.
- Follow-Ups:
- Re: CDC Floating point = tests?
- From: stocksami@xxxxxxxxxxxxx
- Re: CDC Floating point = tests?
- References:
- CDC Floating point = tests?
- From: stocksami@xxxxxxxxxxxxx
- CDC Floating point = tests?
- Prev by Date: Re: CVF and Vista
- Next by Date: Re: F77 -> F95 Intro Presentation Material
- Previous by thread: Re: CDC Floating point = tests?
- Next by thread: Re: CDC Floating point = tests?
- Index(es):
Relevant Pages
|