C99 comparison macro's

S

Serve La

Now that implementations are becoming available, I've started to
learn more about C99.
Now I was reading about the isgreater/isgreaterequal/isless/...
macro's and I'm wondering about why they are here? What's the
difference with the normal relational operators?
 
A

Andreas Kahari

Now that implementations are becoming available, I've started to
learn more about C99.
Now I was reading about the isgreater/isgreaterequal/isless/...
macro's and I'm wondering about why they are here? What's the
difference with the normal relational operators?


The macros does not, according to the standard, raise the
"invalid" floating-point exception when the arguments are
unordered (one of them is NaN). According to the rationale, the
macros were chosen instead of new operators like ?<, ?<=, ?>=,
and ?> since new operators for florating-point only would be a
too great a change to the base language. The macros do not work
with integers, since there is no NaN integer.
 
I

Irrwahn Grausewitz

Serve La said:
Now that implementations are becoming available, I've started to
learn more about C99.
Now I was reading about the isgreater/isgreaterequal/isless/...
macro's and I'm wondering about why they are here? What's the
difference with the normal relational operators?

From ISO/IEC 9899:1999 Annex F.3:

[...]
The relational and equality operators provide IEC 60559 comparisons.
IEC 60559 identifies a need for additional comparison predicates to
facilitate writing code that accounts for NaNs. The comparison macros
(isgreater, isgreaterequal, isless, islessequal, islessgreater, and
isunordered) in <math.h> supplement the language operators to address
this need. The islessgreater and isunordered macros provide respectively
a quiet version of the <> predicate and the unordered predicate
recommended in the Appendix to IEC 60559.

Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top