Rate This Document
Findability
Accuracy
Completeness
Readability

fmaxmag

Return an input parameter with a larger absolute value. Otherwise, the function behaves like fmax(x, y).

Interface Definition

C interface:

float fmaxmagf(float x, float y);

double fmaxmag(double x, double y);

Parameters

Parameter

Type

Description

Input/Output

x

  • For fmaxmagf, x is of single-precision floating-point type.
  • For fmaxmag, x is of double-precision floating-point type.

Floating-point value of the input data.

Input

y

  • For fmaxmagf, y is of single-precision floating-point type.
  • For fmaxmag, y is of double-precision floating-point type.

Floating-point value of the input data.

Input

Return Value

The input parameter (x or y) whose absolute value is larger is returned. If |x| > |y|, the return value is x; if |y| > |x|, the return value is y. Otherwise, the function behaves like fmax(x, y).

  • If both x and y are NaN, the return value is +NaN.
  • If x is NaN and y is any value but NaN, the return value is y.
  • If x is any value but NaN and y is NaN, the return value is x.

Dependency

C: "km.h"

Example

C interface:
    // typical usage
    printf("fmaxmag(1.0, 2.0) = %.15f\n", fmaxmag(1.0, 2.0));
    printf("fmaxmag(3.0, 2.0) = %.15f\n", fmaxmag(3.0, 2.0));
    // special handing
    printf("fmaxmag(NAN, -NAN) = %.15f\n", fmaxmag(NAN, -NAN));
    printf("fmaxmag(NAN, -INFINITY) = %.15f\n", fmaxmag(NAN, -INFINITY));

result
    /* 
     * fmaxmag(1.0, 2.0) = 2.000000000000000
     * fmaxmag(3.0, 2.0) = 3.000000000000000
     * fmaxmag(NAN, -NAN) = nan
     * fmaxmag(NAN, -INFINITY) = -inf
     * */