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


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>


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