Comparisons

The computational model fails in one important instance. When one or the other of x and y is a NaN, the expression (x < y) is certainly not true, but neither is its complement in the real number system, (x >= y). NaNs can undermine code of the form

      if (x < y)
          // consequence
      else
          // alternative, possibly written assuming x >= y
especially such code written before widespread use of the IEEE arithmetic standards. The question, "Is x less than y?" requires more than a No answer. Following the IEEE standards, CommonPoint platforms raise the invalid flag when the arguments to one of the built-in comparison operators <, <=, >=, and > are unordered.

When you wish to avoid raising an unwanted flag, you can use one of the comparison macro functions: IsLess, IsLessEqual, IsGreaterEqual, IsGreater, IsUnordered, and IsLessGreater. They perform the specified comparison on their two arguments, returning a bool result but never raising a flag.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker