This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Comparing doubles


Tim Hollebeek <tim@hollebeek.com> writes:
> On Sun, Jul 07, 2002 at 09:09:45AM -0400, Paul Koning wrote:
> > As for compare, I don't claim to know the intricacies of IEEE NaN and
> > all that, but surely on older float formats at least, compare is
> > indeed internally just a subtract and test for zero?
> The original suggestion, which seems to be missed by many, was
> subtract _doubles_ and compare to _float_ zero.

Yes.

Some more information about the floating-point format (not IEEE) in
question: there are no NaNs, infinities, or -0.  FLT_MIN ==
(float)DBL_MIN.  The double format is just a float number with an
extra word of mantissa.

I think this means that the proposed operation (subtraction followed
by truncation and comparison against zero) will only fail if there is
an operand that is too small to be normalized.

-- 
Lars Brinkhoff          http://lars.nocrew.org/     Linux, GCC, PDP-10,
Brinkhoff Consulting    http://www.brinkhoff.se/    HTTP programming


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]