Developer Guide and Reference

ID 767251
Date 10/31/2024
Public
Document Table of Contents

IEEE_MAX_NUM

Inquiry Module Intrinsic Function (Generic): Returns the numeric maximum of two values. This is equivalent to the IEEE maximumNumber operation.

Module

USE, INTRINSIC :: IEEE_ARITHMETIC

result = IEEE_MAX_NUM (x,y)

x

(Input) Must be of type REAL.

y

(Input) Must be of type REAL with the same kind type parameter as x.

Results

The result type is REAL with the same kind type parameter as x. If x > y, the result is x. If y > x, the result is y. If x == y and both have the same sign, the result is either x or y. If one, but not both of x and y is a NaN, the result is the other argument. If both arguments are NaNs, the result is a quite NaN. Otherwise, one argument is negative zero, the other is positive zero, and the result is positive zero.

If either or both of the arguments is a signaling NaN, the exception IEEE_INVALID is signaled. Unless both arguments are signaling NaNs, the signaling NaN is otherwise ignored and not converted to a quiet NaN. No other exceptions are signaled.

This is the maximumNumber operation as specified in the ISO/IEC 60559:2020 standard.

Example

The result value of IEEE_MAX_NUM (3.7, IEEE_VALUE (0.0, IEEE_SIGNALING_NAN)) is 3.7. The exception IEEE_INVALID is signaled.