Some differences between Maple and the IEEE/754 Standard

Types versus Predicates



Whereas the IEEE/754 Standard refers to recommended predicates for obtaining information about objects (for example, isnan(x)), Maple uses its type system for this purpose. For example:

Maple

IEEE



type(x,undefined)

isnan(x)

type(x,finite)

finite(x)




In addition, Maple has a wide variety of types for obtaining more precise information about a numeric object. Some examples are type/infinity, type/extended_numeric, type/complex, type/float, many of which are actually structured types, allowing even further refinement, such as type(x, complex(float)), type(x, imaginary(infinity)), etc. See Numeric Types in Maple.


The IEEE/754 query routine class(x) is implemented in Maple as NumericClass(x), which returns a type that accepts x and allows you to distinguish x from other elements of the numeric system. For example, NumericClass(Float(infinity)) returns And(sfloat, negative, infinity).



Comparison



Maple implements the basic comparison operators =, <>, >, <, >=, and <=, as well as two others which are implemented as predicates: OrderedNE() (for "ordered and not equal") and Unordered(). There are, however, some slight differences between the IEEE/754 Standard specifications for these operators and predicates and what Maple implements. These differences largely arise from the need for Maple's operators to deal with symbolic expressions. The differences are:

•

Maple's "not equal" operator, <>, is what the IEEE/754 Standard denotes by ?<> ("unordered or not equal"); it returns true without signaling if one of the operands is undefined.

•

The IEEE/754 operator <> ("less than or greater than") is Maple's OrderedNE() predicate.

•

Maple's relational operators do not signal Invalid if an operand is undefined.

•

Complex numbers (expressions of type nonreal in Maple) are considered to be unordered with respect to everything. A comparison such as 3 + I < 4 will return false and will signal invalid.

•

When a result is not immediately required (for example, when assigning a relation expression to another variable), Maple will leave relational expressions unevaluated if it cannot determine the result outright.



Default Results From Events



If a trap handler has been installed for either the overflow or underflow event, the default result delivered to that handler is as just described, rather than the IEEE/754 default value which is a scaled version of the correct result.


Note: Since the handler also receives the operands to the operation which resulted in the overflow or underflow event, the handler can reconstruct the IEEE/754 default result should this be desired.



The real_to_complex Event



Maple's default computational environment is the complex numbers, but it is often useful to try to keep computations inside the real number domain. To this end, Maple provides an additional event, called real_to_complex, which is signaled whenever the input(s) to an operation is (are all) extended real numerics while the output is complex.


For example, Maple's square root function is defined over the complex numbers, and, unlike the IEEE/754 sqrt() function, does not signal the invalid_operation event if passed a negative number. However, it will signal real_to_complex and pass the correct mathematical value as the default return value should this event not be trapped.


