(j3.2006) IEEE comparisons

Robert Corbett robert.corbett
Tue Aug 16 21:59:39 EDT 2016



On 8/16/2016 9:19 AM, Fred J. Tydeman wrote:
> On Mon, 15 Aug 2016 23:08:56 -0700 Robert Corbett wrote:
>> The current wording of the standard indicates that the
>> comparison operations should generate at most one exception.
>> That is fine for comparisons when the operands have the
>> same format, but it is a problem when the operands have
>> different formats.
> Can you give an example of why you think that is a problem?
>
> When a narrow format is converted to a wider format, no exception is raised.

Conversions from one internal format to another are
general-computational operations.  Therefore, a
conversion must signal an invalid operand exception
if its operand is a signaling NaN.

Suppose the format of one operand of a comparison is
binary32 and the format of the other operand is
binary64.  IEEE Std. 754:2008 defines the
comparison as a single operation.  Therefore, the
comparison should signal an exception at most once.
The usual implementation of the comparison would be
to convert the binary32 operand to a wider format
and then do a homogeneous comparison.  If the
binary32 operand is a signaling NaN, it will
signal an invalid operand exception when it does the
conversion, and if the comparison is a signaling
comparison, it will signal another invalid
operand exception when it does the comparison.

Similar issues arise for arithmetic operations.
In the case of arithmetic operations, there is a
note at the end of subclause 5.4.1 that says that,
subject to certain conditions, the arithmetic
operations may be implemented as sequences of
other operations.  A possible fix for the issue
would be to add a similar note for comparisons.

Bob Corbett



More information about the J3 mailing list