This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Comparing doubles
- From: Geoff Keating <geoffk at geoffk dot org>
- To: Lars Brinkhoff <lars at nocrew dot org>
- Cc: gcc at gcc dot gnu dot org
- Date: 01 Jul 2002 11:55:41 -0700
- Subject: Re: Comparing doubles
- References: <8565zziaat.fsf@junk.nocrew.org>
Lars Brinkhoff <lars@nocrew.org> writes:
> Does the C standard define exactly how floating-point comparisons
> should work?
No, it doesn't. Most of the specification is in appendix F, but that
appendix is optional.
> Sections 6.5.8 Relational operators and 6.5.9 Equality
> operators in C99 doesn't spell out any details.
>
> In particular, would it be acceptable for a GCC back end to compare
> two doubles by subtracting them, converting the result to float, and
> then compare the result against zero?
If you define __STDC_IEC_559__, no. Otherwise, you can do whatever
you like, although it might give a less-than-useful FP implementation.
--
- Geoffrey Keating <geoffk@geoffk.org> <geoffk@redhat.com>